【发布时间】:2016-02-23 07:02:11
【问题描述】:
我试图查看其他相关帖子,但我仍然卡住了
我的头文件看起来像这样
节点.hpp
#include<iostream>
using namespace std;
#ifndef NODE_HPP
#define NODE_HPP
struct Node
{
int value;
Node *start;
Node *end;
}
*start, *end;
int count= 0;
#endif
和
队列.hpp
#include<iostream>
using namespace std;
#ifndef QUEUE_HPP
#define QUEUE_HPP
#include "Node.hpp"
class Queue{
public:
Node *nNode(int value);
void add(int value);
void remove();
void display();
void firstItem();
Queue()
{
start = NULL;
end = NULL;
}
};
#endif
我的队列实现看起来像
#include<iostream>
using namespace std;
#include "Queue.hpp"
#include<cstdio>
#include<cstdlib>
主要看起来像
#include<iostream>
using namespace std;
#include "Queue.hpp"
#include<cstdio>
#include<cstdlib>
我收到以下错误
/tmp/ccPGEDzG.o:(.bss+0x0): multiple definition of `start'
/tmp/ccJSCU8M.o:(.bss+0x0): first defined here
/tmp/ccPGEDzG.o:(.bss+0x8): multiple definition of `end'
/tmp/ccJSCU8M.o:(.bss+0x8): first defined here
/tmp/ccPGEDzG.o:(.bss+0x10): multiple definition of `count'
/tmp/ccJSCU8M.o:(.bss+0x10): first defined here
我在这里做错了什么?
【问题讨论】:
-
你可以尝试删除这个
using namespace std;stackoverflow.com/questions/1452721/… 或者至少把它放在你的标题保护中在你所有的#includes
标签: c++ definition