为什么总是编译错误呢???
为什么在visual C++中编译下面的程序就弹出个窗口:x.rc(x为程序的名字)进行访问时发生了一个不明确的错误???用C-free 却能编译和运行!?
[code=C/C++][/code]
#include<iostream>
using namespace std;
class animal
{
friend void setvalue(animal &,int,int);
public:
void print()
{
cout<<"weight"<<itsweight<<endl;
cout<<"age:"<<itsage<<endl;
}
protected:
int itsweight;
int itsage;
};
void setvalue(animal &ta,int tw,int tn=0)
{
ta.itsweight=tw;
ta.itsage=tn;
}
int main()
{
animal peppy;
setvalue (peppy,5);
cout<<"1:"<<endl;
peppy.print();
setvalue(peppy,7,9);
cout<<"2:"<<endl;
peppy.print();
return 0;
}
[解决办法]
vc 6 编译没什么错误呀!
#include<iostream>using namespace std;class animal{ friend void setvalue(animal &,int,int);public: void print() { cout<<"weight"<<itsweight<<endl; cout<<"age:"<<itsage<<endl; } protected: int itsweight; int itsage;};void setvalue(animal &ta,int tw,int tn=0){ ta.itsweight=tw; ta.itsage=tn;}int main(){ animal peppy; setvalue (peppy,5); cout<<"1:"<<endl; peppy.print(); setvalue(peppy,7,9); cout<<"2:"<<endl; peppy.print(); return 0;}
[解决办法]
另外插入代码应该向下面那样子插入!
[解决办法]
是不是编译器少了啥东西
或者你没有以控制台方式编译程序
[解决办法]
rc 文件的支持有差别的
可以去除 rc 文件再编译