C++简单继承
来源:互联网 发布:绿蔓的读音知乎 编辑:程序博客网 时间:2024/06/06 00:37
#include<iostream>using namespace std;class People{private: string name; int id;protected: int age; void hehe(){ cout << "hehe" << endl; }public: People(){name="NULL";id=-1;} People(string nm,int i):name(nm),id(i){} void shout(){ cout << "Aiyooooo... I'm " << name <<'\t' << endl; hehe(); } void setId(int i){ id=i; } void setname(string n){name=n;} string getname(){return name;}};class Student:public People{private: int sid; // int score;public: Student(){ People(); sid=999; } Student(string nm,int i,int s) :People (nm,i),sid(s){} string getname(){return People::getname();} void learn(){ cout <<sid<<endl; } void shout(){ cout << "Haha...I'm" <<getname() << endl; }};int main(){ // People zs("Z",1001); Student ls("Lisi",1001,999); ls.learn(); ls.shout(); return 0;}
阅读全文
0 0
- C++:简单的继承理解
- 【C++】继承的简单了解!!!
- 从 C++ 到 Objective-C-------简单继承
- 【C++】简单的继承执行顺序
- 简单继承
- 一个简单的类的继承的写法(C#)
- java,c#,php类与继承简单比较
- 纯C语言实现简单封装继承机制
- c继承
- C++----------------继承
- 【c#】继承
- C++:继承
- C++::继承
- [C++]继承
- 【C++】继承
- 【C#】继承
- 【c++】继承
- 【C++】继承
- HDH 1264 Counting Squares (线段树+扫描线|暴力)
- map使用
- android 自定义 View(1)
- 面向对象三大特征
- linux command : local/locale/locate
- C++简单继承
- Android 上的低功耗蓝牙实践
- a+b
- 【剑指offer】最小的K个数
- 机器学习算法(二)逻辑斯蒂回归
- ACM国家集训队论文
- Class类(1)
- Java 中十进制和十六进制的相互转换
- [CODEVS2145]判断奇偶性