Error : 'ClassName' does not name a type
Error : 'ClassName' does not name a type
我知道这个错误是不言自明的,但我似乎无法在我的 code.All 中找到内部问题 me.Anyway 似乎很好 me.Anyway 有我的头文件 :
GList.h :
#ifndef LIST_H_
#define LIST_H_
#include "GNode.h"
class GList {
GNode *head,*last;
int size;
public:
GList();
~GList();
Functions();
};
#endif
GNode.h :
#pragma once
#include "VList.h"
#include "Key.h"
class GNode
{
Key value;
VList *Vec_in; // Vertex List
VList *Vec_out;
GNode *next, *prev;
public:
GNode();
GNode(Key );
~GNode();
Functions();
};
VList.h :
#ifndef LIST_H_
#define LIST_H_
#include "VNode.h"
class VList {
VNode *head,*last;
int size;
public:
VList();
~VList();
Functions();
};
#endif
VNode.h :
#pragma once
class Vertex;
class VNode
{
Vertex *value;
VNode *next, *prev;
public:
VNode();
VNode(Vertex *);
~VNode();
Functions();
};
class Vertex {
int trans_amount;
VNode *Start; // The VNode that the vertex beggins from
VNode *Dest; // the destination node that vertex ends up
public:
Vertex();
Vertex(int);
~Vertex();
Functions();
};
main.cpp(不知道是不是needed.It只是一个简单的主要检查代码):
#include <iostream>
#include "GList.h"
using namespace std;
int main(int argc, char **argv) {
GList *list = new GList;
for (int i = 0; i < 20; i++) {
Key x(i);
list->Push(x);
}
list->PrintList();
delete list;
return 0;
}
当我尝试编译 im 时出现以下错误:
In file included from GList.h:4:0,
from GList.cpp:1:
GNode.h:11:2: error: ‘VList’ does not name a type
VList *Vec_in; // Vertex List
^
GNode.h:12:2: error: ‘VList’ does not name a type
VList *Vec_out;
^
In file included from GList.h:4:0,
from main.cpp:3:
GNode.h:11:2: error: ‘VList’ does not name a type
VList *Vec_in; // Vertex List
^
GNode.h:12:2: error: ‘VList’ does not name a type
VList *Vec_out;
VList 和 VNode 源文件可以正常工作,因为在不同的 main 中我得到了预期的结果,所以我猜我缺乏关于前向声明的知识或缺少一些真正基本的东西。
PS:我找不到 post .cpp 文件的充分理由,因为它包含错误。
您的 include 守卫似乎有(copy/paste?)问题。在 GList.h
中应该有
#ifndef GLIST_H_
#define GLIST_H_
...
#endif
并在 VList.h
#ifndef VLIST_H_
#define VLIST_H_
...
#endif
我知道这个错误是不言自明的,但我似乎无法在我的 code.All 中找到内部问题 me.Anyway 似乎很好 me.Anyway 有我的头文件 :
GList.h :
#ifndef LIST_H_
#define LIST_H_
#include "GNode.h"
class GList {
GNode *head,*last;
int size;
public:
GList();
~GList();
Functions();
};
#endif
GNode.h :
#pragma once
#include "VList.h"
#include "Key.h"
class GNode
{
Key value;
VList *Vec_in; // Vertex List
VList *Vec_out;
GNode *next, *prev;
public:
GNode();
GNode(Key );
~GNode();
Functions();
};
VList.h :
#ifndef LIST_H_
#define LIST_H_
#include "VNode.h"
class VList {
VNode *head,*last;
int size;
public:
VList();
~VList();
Functions();
};
#endif
VNode.h :
#pragma once
class Vertex;
class VNode
{
Vertex *value;
VNode *next, *prev;
public:
VNode();
VNode(Vertex *);
~VNode();
Functions();
};
class Vertex {
int trans_amount;
VNode *Start; // The VNode that the vertex beggins from
VNode *Dest; // the destination node that vertex ends up
public:
Vertex();
Vertex(int);
~Vertex();
Functions();
};
main.cpp(不知道是不是needed.It只是一个简单的主要检查代码):
#include <iostream>
#include "GList.h"
using namespace std;
int main(int argc, char **argv) {
GList *list = new GList;
for (int i = 0; i < 20; i++) {
Key x(i);
list->Push(x);
}
list->PrintList();
delete list;
return 0;
}
当我尝试编译 im 时出现以下错误:
In file included from GList.h:4:0,
from GList.cpp:1:
GNode.h:11:2: error: ‘VList’ does not name a type
VList *Vec_in; // Vertex List
^
GNode.h:12:2: error: ‘VList’ does not name a type
VList *Vec_out;
^
In file included from GList.h:4:0,
from main.cpp:3:
GNode.h:11:2: error: ‘VList’ does not name a type
VList *Vec_in; // Vertex List
^
GNode.h:12:2: error: ‘VList’ does not name a type
VList *Vec_out;
VList 和 VNode 源文件可以正常工作,因为在不同的 main 中我得到了预期的结果,所以我猜我缺乏关于前向声明的知识或缺少一些真正基本的东西。
PS:我找不到 post .cpp 文件的充分理由,因为它包含错误。
您的 include 守卫似乎有(copy/paste?)问题。在 GList.h
中应该有
#ifndef GLIST_H_
#define GLIST_H_
...
#endif
并在 VList.h
#ifndef VLIST_H_
#define VLIST_H_
...
#endif