首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > C++ >

为什么总是编译异常呢?

2012-04-07 
为什么总是编译错误呢???为什么在visual C++中编译下面的程序就弹出个窗口:x.rc(x为程序的名字)进行访问时

为什么总是编译错误呢???
为什么在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 编译没什么错误呀!

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;}
[解决办法]
另外插入代码应该向下面那样子插入!


[解决办法]
是不是编译器少了啥东西
或者你没有以控制台方式编译程序
[解决办法]
rc 文件的支持有差别的

可以去除 rc 文件再编译

热点排行
Bad Request.