继承
来源:互联网 发布:淘宝官网电话400 编辑:程序博客网 时间:2024/05/16 12:05
#include <iostream> using namespace std; class Animal{private:char name[20];protected:int age;public:void set_name(char* name){strcpy(this->name, name);}void set_age(int age){this->age = age;}char* get_name(){return name;}int get_age(){return age;}};class Bird : public Animal{double weight;public:void set_weight(double weight){this->weight = weight;}double get_weight(){return weight;}void fly(){cout << "我终于翱翔用心凝望不害怕" << endl;}};int main(){Bird a1;a1.set_name("麻雀");a1.set_age(27);a1.set_weight(100);cout << a1.get_name() << ':' << a1.get_age() << "岁" << "体重" << a1.get_weight() << endl;a1.fly();return 0;}
阅读全文
0 0
- 继承
- 继承
- 继承
- 继承
- 继承
- 继承
- 继承
- 继承
- 继承
- 继承
- 继承
- 继承
- 继承
- 继承
- 继承
- 继承
- 继承
- 继承
- YOLO9000: Better, Faster, Stronger
- leetcode 59. Spiral Matrix II
- Android最流行开源工具库
- 1010. 一元多项式求导 (25)
- Google/LintCode:M-搜索二维矩阵 II
- 继承
- 图论500题!
- 电话,手机,微信账号,邮箱正则表达式校验
- codeforces [Gym-100814G]
- mysql单表百万数据记录分页性能优化
- hoj 2430 Counting the algorithms(树状数组,贪心)
- 微信小程序开发animation心跳动画
- CVE-2016-5195 Dirty-cow 简单分析
- 2017夏天之哪凉快去哪里 之五