完成如下的程序,使得输出为:
1234
#include <iostream.h>
#include <math.h>
class A
{
private:
________(1)___________
protected:
________(2)__________
public:
A(int a, int b, int c)
{
X=a;
Y=b;
Z=c;
}
int GetX()
{
return X;
}
int GetY()
{
return Y;
}
int GetZ()
{
return Z;
}
};
class B _____(3)_______
{
private:
int K;
public:
B(int a, int b, int c, int d)_______(4)_________
{
K=d;
}
void Show()
{
cout << GetX() << GetY() << Z << K << endl;
}
};
void main()
{
B b(1,2,3,4);
b.Show();
}
c++程序填空题
答案:3 悬赏:80 手机版
解决时间 2021-02-19 09:59
- 提问者网友:记得曾经
- 2021-02-18 22:25
最佳答案
- 五星知识达人网友:山河有幸埋战骨
- 2021-02-18 22:43
//1234
#include <iostream.h>
#include <math.h>
class A
{
private:
//________(1)___________
int X,Y;
protected:
//________(2)__________
int Z;
public:
A(int a, int b, int c)
{
X=a;
Y=b;
Z=c;
}
int GetX()
{
return X;
}
int GetY()
{
return Y;
}
int GetZ()
{
return Z;
}
};
class B : public A//_____(3)_______
{
private:
int K;
public:
B(int a, int b, int c, int d): A(a,b,c)//_______(4)_________
{
K=d;
}
void Show()
{
cout << GetX() << GetY() << Z << K << endl;
}
};
void main()
{
B b(1,2,3,4);
b.Show();
}
//别忘了给分~
#include <iostream.h>
#include <math.h>
class A
{
private:
//________(1)___________
int X,Y;
protected:
//________(2)__________
int Z;
public:
A(int a, int b, int c)
{
X=a;
Y=b;
Z=c;
}
int GetX()
{
return X;
}
int GetY()
{
return Y;
}
int GetZ()
{
return Z;
}
};
class B : public A//_____(3)_______
{
private:
int K;
public:
B(int a, int b, int c, int d): A(a,b,c)//_______(4)_________
{
K=d;
}
void Show()
{
cout << GetX() << GetY() << Z << K << endl;
}
};
void main()
{
B b(1,2,3,4);
b.Show();
}
//别忘了给分~
全部回答
- 1楼网友:拾荒鲤
- 2021-02-19 00:45
题有问题吧 A A为啥没调用
- 2楼网友:woshuo
- 2021-02-18 23:06
#include <iostream> using namespace std; class test { private: int x,y; public: test(){x=y=0; } test(int a, int b) { x=a;y=b; } void print(){cout<<"x="<<x<<"y="<<y<<endl;} }; void main() { test t1(100,200),t2; test *p[]={(test*)&t1,(test*)&t2}; int i; for(i=0;i<=1;i++) p[i]->print(); }
我要举报
如以上问答信息为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯