C++上机实验报告 实验名称:类和对象 专业班级: 姓 名: 学 号: 实验日期: 目录 1 . 实验目的 2 . 实验内容 3 . 程序代码 4 . 调试结果 5 . 实验心得 1. 实验目的 (1) 进一步加深对类和对象的理解; (2) 掌握类的构造函数和析构函数的概念和使用方法; (3) 掌握对象数组,对象的指针及其使用方法; (4) 掌握友元的概念和使用; (5) 了解类模板的使用方法。 2. 实验内容 (1) 有以下程序: #include 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< using namespace std; class Date; //对 Date 类的提前引用声明 class Time //定义Time 类 {public: Time(int,int,int); void display(Date &); //display 是成员函数,形参是Date 类对象的引用 private: int hour; int minute; int sec; }; class Date //声明Date 类 {public: Date(int,int,int); friend void Time::display(Date &); //声明Time 中的display 函数为友元成员函数 private: int month; int day; int year; }; Time::Time(int h,int m,int s) //类Time 的构造函数 {hour=h; minute=m; sec=s; } void Time::display(Dat...