【发布时间】:2010-04-21 00:54:20
【问题描述】:
我有这个 cpp 文件。
dsets.cpp:
#ifndef DSETS_CPP
#define DSET_CPP
//Adds elements to the DisjointSet data structure. This function adds
//x unconnected roots to the end of the array.
void DisjointSets::addelements(int x){
}
//Given an int this function finds the root associated with that node.
int DisjointSets::find(int x){
return 0;
}
//This function reorders the uptree in order to represent the union of two
//subtrees
void DisjointSets::setunion(int x, int y){
}
#endif
还有这个头文件
dsets.h:
#ifndef DSETS_H
#define DSET_H
#include <iostream>
#include <vector>
using namespace std;
class DisjointSets
{
public:
void addelements(int x);
int find(int x);
void setunion(int x, int y);
private:
vector<int> x;
};
#include "dsets.cpp"
#endif
而且我不断收到一条错误消息,提示“未声明不相交集”
~
~
【问题讨论】:
-
你的编译命令是什么样的?
-
另外,我不知道是不是拼写错误,但用于#ifndef 和#define 的标记应该是相同的。
-
另外一件事,不要放“using namespace ...;”在头文件中。
标签: c++ compilation undeclared-identifier