标题:c++小程序,有一个错误。求高人指点
取消只看楼主
杨龙龙
Rank: 2
等 级:论坛游民
帖 子:17
专家分:29
注 册:2012-3-8
结帖率:100%
已结贴  问题点数:10 回复次数:0 
c++小程序,有一个错误。求高人指点
#include<iostream>
#include<string>
using namespace std;
class Student
{
public:
    Student(int ,string,float);
    void display();
private:
    int num;
    string name;
    float score;
};
Student::Student(int n,string nam,float s)
{
    num=n;
    name=nam;
    score=s;
}
void Student::display()
{
    cout<<num<<name<<score<<endl;
}
class Graduate:public Student
{
    Graduate (int ,string ,float ,float);
    void display();
private:
    float pay;
};
Graduate::Graduate(int n,string nam,float s,float p):Student(n,nam,s),pay(p){}
void Graduate::display()
{Student::display();
cout<<pay<<endl;
}
int main()
{
    Student stud1(1001,"liuanglong",3.3);
    Graduate grad1(2001,"dsddfkjjdfhgkjdf",33.3,33.333);
    Student *p=&stud1;
    p->display();
    p=&grad1;
    p->display();
}


搜索更多相关主题的帖子: void class private display include 
2012-03-28 23:27



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-364633-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.392796 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved