- UID
- 28208
- 帖子
- 18803
- 积分
- 56605
- 阅读权限
- 90
- 注册时间
- 2006-9-4
- 最后登录
- 2015-6-1
- 在线时间
- 12541 小时
- 战队
- [SvS]
- 联赛ID
- PY_Shmily
- 种族
- Protoss
- 战队
- [SvS]
- 联赛ID
- PY_Shmily
- 种族
- Protoss
|
达到了最低要求
#include<iostream>
using namespace std;
class CBase
{
protected:
int first;
int second;
public:
CBase(int xx=0,int yy=0)
{
first=xx;
second=yy;
}
int GetFirst()
{
return first;
}
int GetSecond()
{
return second;
}
void PringInfo()
{
cout<<"第一个数是"<<first<<"第二个数是"<<second;
}
};
class CDerived:public CBase
{
private:
int third;
public:
CDerived(int xx=0,int yy=0,int zz=0):CBase(xx,yy)
{
third=zz;
}
void CDerived::SetFST(int first,int second,int third)
{
this->first=first;
this->second=second;
this->third=third;
}
int GetThird()
{
return third;
}
int sum;
int Sum()
{
sum=first+second+third;
return sum;
}
void PrintInfo()
{
CBase: ringInfo();
cout<<"第三个数是"<<third<<endl;
cout<<"这三个数之和是"<<sum<<endl;
cout<<endl;
}
};
void main()
{
CDerived s[2];
s[0].SetFST(2,3,4);
s[0].Sum();
s[0].PrintInfo();
s[1].SetFST(555,63,521);
s[1].Sum();
s[1].PrintInfo();
} |
|