错误:"类名"未命名类型
Error : 'ClassName' does not name a type
我知道这个错误是不言自明的,但我似乎无法在我的代码中找到内部问题。对我来说,一切似乎都很好。无论如何,有我的头文件:
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(我不知道是否需要。这只是一个简单的主要检查代码):
#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;
}
当我尝试编译时,我收到以下错误:
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 源文件正在工作,因为在不同的主文件中,我得到了我期望的结果,所以我猜我缺乏关于正向声明的知识或缺少一些真正基本的东西。
附注:I没有找到发布.cpp文件的充分理由,因为它是包含错误。
您的包含守卫似乎存在(复制/粘贴?在GList.h
应该有
#ifndef GLIST_H_
#define GLIST_H_
...
#endif
并在VList.h
#ifndef VLIST_H_
#define VLIST_H_
...
#endif
相关文章:
- 未命名的非类型模板参数有什么意义?
- C++包含函数标头会给出错误'__dest'未命名类型
- 错误:"cast"未命名类型void setCastDescription(std::string
- C++ 错误:(类名)未命名类型
- C++ ,错误:命名空间'std'中的'shared_ptr'未命名模板类型
- src/caffe/parallel.cpp:70:1:错误:“参数”未命名类型
- 错误:'int_type'未命名类型 - 如何继承 typedefs 和用法
- 如何修复错误,迭代器未在此范围内声明,并且迭代器未命名类型'
- 使用 mex 编译库时出错 - __int 64 未命名类型
- 错误:"某个类"未命名类型。如何解决这个问题?
- 命名空间中的'bad_cast' 'std' 未命名类型错误
- QT:错误 ["*"令牌之前的预期")",并且主窗口未命名类型]
- 命名结构与未命名结构的类型别名
- "root"未命名类型错误
- Stack.h:13:3:错误:“单元格”未命名类型
- 错误:命名空间“PQXX”中的“行”未命名类型
- YYY 中的错误 XXX 未命名类型
- C 构建错误:类未命名类型
- 错误:"QGeo坐标"未命名类型
- 错误:"__NDK_FPABI__"未命名类型