64,646
社区成员
发帖
与我相关
我的任务
分享
#include <iostream.h>
class Student
{
public:
Student()
{
cout<<"constructing student.\n";
semesHours = 100;
gpa = 3.5;
}
protected:
int semesHours;
float gpa;
};
class Teacher
{
public:
Teacher()
{
cout<<"constructing teacher.\n";
}
};
class TutorPair
{
public:
TutorPair()
{
cout<<"constructing tutorpair.\n";
}
protected:
Student student;
Teacher teacher;
int noMeeting;
};
void main()
{
TutorPair tp;
cout<<"back in main.\n";
}
主程序里定义了TutorPair tp;为什么先从student类开始难道与保护成员有关