有以下程序,编译时有语法错误,请修改程序,使其能够正确运行,且运行的结果为:
1 1
1
要求:不能修改main函数中的代码。
#include <iostream>
using namespace std;
class A
{
int i,j;
A(int a,int b){i=1;j=1;}
public :
void print(){cout<<i<<" "<<j<<endl;}
};
class B:public A
{
int x;
B(){x=0;}
B(int a){x=a;}
public :
void print(){A::print();cout<<x<<endl;}
};
int main()
{
B b(1);
b.print();
return 0;
}
发过去了,不好意思!