您的位置:首页 > 其它

用指向基类对象的指针输出数据

2008-01-03 09:28 246 查看
#include "stdafx.h"
#include
#include
using namespace std;
class student{
private:
 int num;
 int age;
 float score;
public:
 student(int ,int ,float);
 void display();
};

//定义构造函数
student::student(int n,int a,float sc):num(n),age(a),score(sc){}
void student::display(){//定义成员函数
 cout  pt=&gr;
  pt->display();
  return 0;
 }
 
输出结果:
12222
22
97.4

353543
26
88.2
Press any key to continue 

Trackback: http://tb.blog.csdn.net/TrackBack.aspx?PostId=1476001
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐