问答题

使用VC6打开考生文件夹下的工程RevProj12。此工程包含一个源程序文件RevMain12.cpp,但在该程序中有错误。请改正程序中的错误,使它能得到正确结果。 注意:不得删行或增行,也不得更改程序的结构。 源程序文件RevMain12.cpp中的程序清单如下: //RevMain12.cpp #include<iostream> /* * * * FOUND * * * * */ using namespace std; class test { private: const int value; char dep[10]; public: /* * * * *FOUND* * * * */ test() { value=0; strcpy(dep,"m"); } /* * * * *FOUND* * * * */ test(int newvalue) { value=newvalue; strcpy (dep, "m"); } /* * * * *FOUND * * * * */ void show() { cout<<"value= "<<value<<end1; } }; int main () { test t1; const test t2; t1.show (); t2.show(); return 0; }

【参考答案】

正确的类定义为: #include<iostream> #include<string> using namespace......

(↓↓↓ 点击下方‘点击查看答案’看完整答案 ↓↓↓)
热门 试题