C++问题 fatal error LNK1169: one or more multiply defined symbols found执行 link.exe 时出错.

#include<iostream>
using namespace std;
class Clock{
public:
void setTime(int newH=0,int newM=0,int newS=0);
void showTime();
private:
int hour,minute,second;
};
void Clock::setTime(int newH,int newM,int newS){
hour=newH;
minute=newM;
second=newS;
}
inline void Clock::showTime(){
cout<<hour<<":"<<minute<<":"<<second<<endl;
}
int main(){
Clock myClock;
cout<<"First time set and output:"<<endl;
myClock.setTime();
myClock.showTime();
cout<<"Second time set andoutput:"<<endl;
myClock.setTime(8,30,30);
myClock.showTime();
return 0;
}
用的是VC++6.0,求大神解惑

我编译一切正常啊? 是不是就这个程序有问题?
你把代码贴出来,VC6.0 关掉,再重新建一个cpp文件,把代码粘进去运行一下。
或者你清理一下生成文件,把其他的文件关掉追问

谢谢啊,重建一个CPP文件成功了!但是为什么会出现这种情况,怎么解决呢

追答

是链接错误,以前VC6.0也经常发生。我一般也没管。应该是之前生成的一些东西影响了。
换个IDE吧,VS2010很好。

追问

谢谢!

温馨提示:答案为网友推荐,仅供参考
第1个回答  2012-10-15
嗯嗯
相似回答