*Copyright (c) 2014,烟台大学计算机学院
*All right reserved.
*文件名称:test.cpp
*作 者:韩双志
*完成日期:2016年5月7日
*版本号:v1.0
*
*问题描述:完成各个成员函数,增加构造函数,输出相关信息
*输入描述:无
*输出描述:输出相关信息
/*#include <iostream>
using namespace std;class Person
{
public:
Person(int a,string nam):age(a),name(nam){}
void action();
private:
int age;
string name;
};
void Person::action()
{
cout<<"姓名:"<<name<<endl;
cout<<"年龄:"<<age<<endl;
}
class Point:public Person
{
public:
Point(int a,string nam,int b):Person(a,nam),level(b){}
void arrest(Person);
private:
int level;
};
void Point::arrest(Person a)
{
a.action();
cout<<"级别:"<<level<<endl;
}
class Cook:public Person
{
public:
Cook(int a,string nam,double m):Person(a,nam),salary(m){}
string getCake(int);
private:
double salary;
};
string Cook::getCake(int a)
{
Person::action();
cout<<"薪水"<<a<<endl;
}
int main()
{
Person b(26,"zhangsan");
Point c(20,"lisi",3);
Cook a(26,"hahah",6500);
b.action();
c.arrest(b);
a.getCake(6500);
return 0;
}
*/
运行结果:
知识点结构
类的继承
学习心得
大体为了解了类的继承