#include <iostream.h>
#include<string.h>
class Student
{
public:
Student(char *pName="no name")
{
cout<<"constructing new student "<<pName<<endl;
strcpy(name,pName);
name[sizeof(name)-1]='\0';
}
Student(Student &s)
{
cout<<"constructing copy of "<<s.name<<endl;
strcpy(name,"copy of ");
strcat(name,s.name);
}
~Student()
{
cout<<"destructing "<<name<<endl;
}
protected:
char name[40];
};
class Tutor
{
public:
Tutor(Student &s):student(s)
{
cout<<"Constructing tutor"<<endl;
}
protected:
Student student;
};
void fn(Tutor tutor)
{
cout<<"In function fn()"<<endl;
}
void main()
{
Student randy("randy");
Tutor tutor(randy);
cout<<"calling fn()"<<endl;
fn(tutor); //怎么执行这条语句的,恳请把执行过程写清楚一点,我没搞懂。特别是s是谁的引用,我很糊涂。希望您能给予祥解:)
cout<<"returned from fn()"<<endl;
}