下面的程序中,存在着两处语法错误。请改正错误,使程序按下面输入输出的规定运行。

#include <iostream>
using namespace std;

class A
{
private:
    int a,b;
public:
    A(int aa, int bb) {a=aa; b=bb;}
    void printA()
    {
        cout<<"a: "<<a<<" b: "<<b<<endl;
    }
};
class B: public A
{
    int c;
public:
    B(int aa, int bb, int cc):A(aa,bb){c=cc;}
    void printB()
    {
	    printA();
        cout<<"c: "<<c<<endl;
    }
};
//********************* end ********************
int main()
{
    int a1, a2;
    int b1, b2, b3;
    cin>>a1>>a2;
    cin>>b1>>b2>>b3;
    A a(a1,a2);
    B b(b1,b2,b3);
    a=b;
    a.printA();
    b.printB();
    return 0;
}

 

    原文作者:来个地瓜
    原文地址: https://blog.csdn.net/qq904069486/article/details/84840203
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞