继承
来源:互联网 发布:linux sqlplus 登录 编辑:程序博客网 时间:2024/06/05 03:14
#include <iostream>
using namespace std;
class People
{
private:
char *name;
// int age;
public:
void setname(char *m_name);
//void setage(int m_age);
char *getname();
//int getage();
};
class Student : public People
{
private:
float m_score;
public:
void setscore(float score);
float getscore();
};
int main()
{
Student stu;
stu.setscore(88.5);
stu.setname("xiaoli");
cout<<stu.getscore()<<endl;
cout<<stu.getname()<<endl;
return 0;
}
void Student :: setscore(float score)
{
m_score = score;
}
float Student :: getscore()
{
return m_score;
}
void People :: setname(char *m_name)
{
name = m_name;
}
char* People ::getname()
{
return name;
}
using namespace std;
class People
{
private:
char *name;
// int age;
public:
void setname(char *m_name);
//void setage(int m_age);
char *getname();
//int getage();
};
class Student : public People
{
private:
float m_score;
public:
void setscore(float score);
float getscore();
};
int main()
{
Student stu;
stu.setscore(88.5);
stu.setname("xiaoli");
cout<<stu.getscore()<<endl;
cout<<stu.getname()<<endl;
return 0;
}
void Student :: setscore(float score)
{
m_score = score;
}
float Student :: getscore()
{
return m_score;
}
void People :: setname(char *m_name)
{
name = m_name;
}
char* People ::getname()
{
return name;
}
阅读全文
0 0
- 继承
- 继承
- 继承
- 继承
- 继承
- 继承
- 继承
- 继承
- 继承
- 继承
- 继承
- 继承
- 继承
- 继承
- 继承
- 继承
- 继承
- 继承
- caffe安装中python下运行缺少的模块
- HDOJ 1241 油田 BFS(使用普通队列或循环队列) 2种方法
- 洛谷 P1712 区间
- SQL 中使用With As处理层级关系小记
- java学习(5) java 数组相关知识
- 继承
- rocketmq环境搭建
- 工业产品设计为产品创新加分
- 2017.07.14【NOIP提高组】模拟赛B组
- Adaboost/Xgboost/lightgbm学习及实践
- storm入门简介及WordCount代码解析(一)
- php常用表单验证类
- 算法系列——Binary Tree Level Order Traversal
- 2016年机器学习简要笔记