哭泣的骆驼 txt:高手请来C++改错题 真的非常感谢

来源:百度文库 编辑:查人人中国名人网 时间:2024/05/04 16:28:13
5.找出下面程序中的错误,并改正
class A {
int a,b;
public:
A(int aa=0, int bb){
a=aa; b=bb;
}
};
6.找出下面程序中的错误,并改正
# include <iostream.h>
class Test{
private:
static int x;
public:
virtual static int func ();
};
int Test::x=20;
int Test::func()
{
return x;
}
void main()
{
cout<<Test::func()<<endl;
Test a;
cout<<a.func();

5.class A {
int a,b;
public:
A(int aa=0, int bb=0){ 或者 A(int bb,int aa=0 ){
a=aa; b=bb;
}
};

6。
#include <iostream.h>
class Test
{
private:
static int x;
public:
static int func (); //静态成员函数不能做成虚函数
};
int Test::x=20;
int Test::func()
{
return x;
}
void main()
{
cout<<Test::func()<<endl;
Test a;
cout<<a.func();
}