C++改错 请在不添加语句的情况下,改正程序中的错误,使之能正确输出信息
#includeusingnamespacestd;classbase{intn1;private:base(intm1){n1=m1;}voidshow(){cout<...
#includeusing namespace std;
class base
{ int n1;
private:
base(int m1) {n1=m1;}
void show(){ cout<<"n1="<<n1<<endl; }
}
class derived:public base
{ int n2;
private:
derived(int m2) { n2=m2; }
void show(){ cout<<"n2="<<n2<<endl;}
}
intmain()
{base A(5);
derived B(10);
A.show();
B.show();
} 展开
class base
{ int n1;
private:
base(int m1) {n1=m1;}
void show(){ cout<<"n1="<<n1<<endl; }
}
class derived:public base
{ int n2;
private:
derived(int m2) { n2=m2; }
void show(){ cout<<"n2="<<n2<<endl;}
}
intmain()
{base A(5);
derived B(10);
A.show();
B.show();
} 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询