C++面向对象部分中多重继承中的默认构造函数怎么写 就如这个题,哪儿错了啊
#include<iostream.h>classA{inta,b;public:A(){a=1;b=2;}intgeta(){returna;}intgetb(){re...
#include <iostream.h>
class A
{
int a,b;
public:
A(){a=1;b=2;}
int geta(){return a;}
int getb(){return b;}
};
class B
{
int x,y;
public:
B(){x=3;y=4;}
int getx(){return x;}
int gety(){return y;}
};
class AB:public A,public B
{
public:
AB():A():B(){}
};
void main()
{
AB obj;
cout<<obj.getx()<<endl;
} 展开
class A
{
int a,b;
public:
A(){a=1;b=2;}
int geta(){return a;}
int getb(){return b;}
};
class B
{
int x,y;
public:
B(){x=3;y=4;}
int getx(){return x;}
int gety(){return y;}
};
class AB:public A,public B
{
public:
AB():A():B(){}
};
void main()
{
AB obj;
cout<<obj.getx()<<endl;
} 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询