第七题第四小题

来源:互联网 发布:mac上photoshop 编辑:程序博客网 时间:2024/05/16 19:35
#include <iostream> using namespace std; class Student  {public:    Student(int n,float s):num(n),score(s){}    void change(int n,float s) {num=n;score=s;}    void display() {cout<<num<<" "<<score<<endl;}   private:     int num;     float score;  };  int main() { Student stud(101,78.5);  const Student *p=&stud;  p->display();  p->change(101,80.5);  p->display();  return 0; } 

0 0