error C2061 错误

Tyrion2017 2014-02-04 11:09:56
两个头文件中的代码:
#ifndef _PRIORITY_H_
#define _PRIORITY_H_
#include "graph.h"


struct Pri_Vertex
{
Pri_Vertex() : key(MAX_INT) {};
Pri_Vertex( Vertex v, int k = MAX_INT ) : ver(v), key(k) {};
Pri_Vertex operator=( const Pri_Vertex& v ) { return Pri_Vertex(v.ver, v.key); }
bool operator!=( const Pri_Vertex& v1 )
{
if( v1.ver.key != ver.key )
return true;
else
return false;
}

Vertex ver;
int key;
};




#ifndef _GRAPH_H_
#define _GRAPH_H_

#include <iostream>
#include "priority_queue.h"
using namespace std;

struct Vertex
{
friend class Graph;

Vertex( VERTEX_COLOR colr = WHITE, Arc* first = 0)
: verColr(colr), firstArc(first), dist(MAX_INT), parent(0) {};
Vertex(const Vertex& v)
: verColr(v.verColr), firstArc(v.firstArc), key(v.key), dist(v.dist), parent(v.parent) {};
Vertex operator=(const Vertex& v) { return Vertex(v); }

VERTEX_COLOR verColr;
Arc* firstArc;
int key;
int dist; // 与初始点的距离
Vertex* parent; // 父节点
};



出现了以下错误:
1>e:\代码\graph\graph1\priority_queue.h(9): error C2061: syntax error : identifier 'Vertex'
1>e:\代码\graph\graph1\priority_queue.h(9): error C2535: 'Pri_Vertex::Pri_Vertex(void)' : member function already defined or declared
1> e:\代码\graph\graph1\priority_queue.h(8) : see declaration of 'Pri_Vertex::Pri_Vertex'
1>e:\代码\graph\graph1\priority_queue.h(19): error C2146: syntax error : missing ';' before identifier 'ver'
1>e:\代码\graph\graph1\priority_queue.h(19): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>e:\代码\graph\graph1\priority_queue.h(19): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int


求指点...
...全文
782 5 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
ztenv 版主 2014-02-12
  • 打赏
  • 举报
回复
引用 3 楼 qq2262988 的回复:
Vertex是我自己写的一个结构体。 确实是互相包含,互相包含不允许吗?应该可以呀。我写的比较乱,两个文件确实都能用到对方文件里的东西。
相互包含就是一个死循环了,
buyong 2014-02-12
  • 打赏
  • 举报
回复
引用 3 楼 qq2262988 的回复:
Vertex是我自己写的一个结构体。 确实是互相包含,互相包含不允许吗?应该可以呀。我写的比较乱,两个文件确实都能用到对方文件里的东西。
of course not allowed. you can use some design pattern(I forgot the name of that pattern)
richyhuang 2014-02-04
  • 打赏
  • 举报
回复
看起来像是变量类型未定义。楼主可以查一下Vertex有没有原型
Tyrion2017 2014-02-04
  • 打赏
  • 举报
回复
Vertex是我自己写的一个结构体。 确实是互相包含,互相包含不允许吗?应该可以呀。我写的比较乱,两个文件确实都能用到对方文件里的东西。
relaxisland 2014-02-04
  • 打赏
  • 举报
回复
这是互相包含啊 第二个文件的 #include "priority_queue.h" 这个需要吗?

65,187

社区成员

发帖
与我相关
我的任务
社区描述
C++ 语言相关问题讨论,技术干货分享,前沿动态等
c++ 技术论坛(原bbs)
社区管理员
  • C++ 语言社区
  • encoderlee
  • paschen
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
  1. 请不要发布与C++技术无关的贴子
  2. 请不要发布与技术无关的招聘、广告的帖子
  3. 请尽可能的描述清楚你的问题,如果涉及到代码请尽可能的格式化一下

试试用AI创作助手写篇文章吧