第3题
2015-06-08 22:33
337 查看
#include <iostream> using namespace std; class Student {public: void get_value(); void display( ); protected : int num; char name[10]; char sex; }; void Student::get_value() {cin>>num>>name>>sex;} void Student::display( ) {cout<<"num: "<<num<<endl; cout<<"name: "<<name<<endl; cout<<"sex: "<<sex<<endl; } class Student1: protected Student {public: void get_value_1(); void display1( ); private: int age; char addr[30]; }; void Student1::get_value_1() {get_value(); cin>>age>>addr; } void Student1::display1( ) {cout<<"num: "<<num<<endl; cout<<"name: "<<name<<endl; cout<<"sex: "<<sex<<endl; cout<<"age: "<<age<<endl; cout<<"address: "<<addr<<endl; } int main( ) {Student1 stud1; stud1.get_value_1(); stud1.display1( ); return 0; }
相关文章推荐
- 黑马程序员——Java基础---IO流<实例>
- Unity3d教程之导入3dMax模型产生问题的解决办法
- 获取裁判文书案号问题的解决过程
- 速查表:常用算法和数据结构的复杂度
- 程序员如何提高影响力
- OJ刷题---渊子赛马
- 南阳17 单调递增最长子序列
- Android学习笔记(九)
- 半个世纪前的"美图秀秀" 揭秘历史照片真面目
- R中的因子变量及处理
- 路由器认识与设置方法
- 一致性hash算法详解
- ExpandableListView 实现分组购物车
- hdu 1086
- FolderSync :The various features and how to use them
- 2015美赛心得总结
- gcc编译报错:程序中有游离的‘\357’‘\273’‘\277’等
- Extjs显示图片
- Android性能优化第二篇--布局优化
- [转载] TCP协议缺陷不完全记录