无语了,搞不出来了,好像又是文件包含的问题,那位好心的大哥进来看看
preson.h
#ifndef person_H
#define person_H
const int NAMELONG=128;
struct Date{ //store date
日期
};
struct pInfo{ //information of a person
人的信息
};
struct Person{
pInfo pinfo; //information of each person itself
Person *parent; //a pointer to his parent 's Personnode
Person *child;
Person *brother;
Person();
Person(const pInfo &x);
};
Person::Person()
{
初始化
}
Person::Person(const pInfo &x)
{
初始化
}
#endif
////////////////////////////////////////////////
familytree.h
#include "person.h "
class familytree{
public:
...
protected:
Person *root; //root of a family
};
#endif
///////////////////////////////////////////////
familytree.cpp
#include "familytree.h "
...
///////////////////////////////////////
#include "familytree.h "
void main()
{
Person p1;
familytree f1;
cout < < " ** " < <endl;
}
/////////////////////////////////////
and the error is as below:
main.obj : error LNK2005: "public: __thiscall Person::Person(void) " (??0Person@@QAE@XZ) already defined in familytree.obj
main.obj : error LNK2005: "public: __thiscall Person::Person(struct pInfo const &) " (??0Person@@QAE@ABUpInfo@@@Z) already defined in familytree.obj
Debug/family.exe : fatal error LNK1169: one or more multiply defined symbols found
///////////////////////////////////
i can 't make it right,who knows where is the problem
"shu ru fa zen me you bu hao shi le.yi huan ye mian jiu bu xing le "
[解决办法]
先占个楼
[解决办法]
将这些都放到cpp文件里面
Person::Person()
{
初始化
}
Person::Person(const pInfo &x)
{
初始化
}
[解决办法]
把Person类的实现放到cpp文件中去