钱能C++教材习题答案十四

   /2005-05-08

                       }
                        else
                        {
                                float y;
                                cout<<"请输入存款数量:";
                                cin>>y;
                                p->Withdrawal(y);
                        }
                }
        }
                //类似        if (i==2)
}
}

第17章

//************
//***17.1*****
//*Daiyuebing*
//************
# include <iostream.h>

class A
{
public:
        A()
        {
                pA=0;
        }
        int GetpA()
        {
                return pA;
        }
        void SetpA(int a)
        {
                pA=a;
        }
private:
        int pA;
};

class B:virtual public A
{
public:

        int OnB()
        {
                return GetpA();
        }
};

class C:virtual public A,public B
{

        int Sc()
        {
                return GetpA();
        }
};

void main()
{
        A x;
        B y;
        C z;
        cout<<x.GetpA()<<endl;
        cout<<y.GetpA()<<endl;
        cout<<z.GetpA()<<endl;
}

 

//************
//***17.2*****
//*Daiyuebing*
//************
class father
{
public:
        drive();
protected:
        repareTV();

};

class mother
{
public:
        song();
private:
        work();
};

class child:public father,public mother
{
public:
        playtable();

};

/*修改
        protected:
                repareTV();

        为
        public:
                repareTV();
*/


相关话题/

  • 领限时大额优惠券,享本站正版考研考试资料!
    大额优惠券
    优惠券领取后72小时内有效,10万种最新考研考试考证类电子打印资料任你选。涵盖全国500余所院校考研专业课、200多种职业资格考试、1100多种经典教材,产品类型包含电子书、题库、全套资料以及视频,无论您是考研复习、考证刷题,还是考前冲刺等,不同类型的产品可满足您学习上的不同需求。 ...
    本站小编 Free壹佰分学习网 2022-09-19