子函数的调用问题求解。。。。。。
#include<iostream>#include<string.h>
using namespace std;
struct SUBJECT //课程信息结构体
{
char name[64]; //课程名称
int level; //课程等级
};
class STUDENT
{
public:
STUDENT(int nMax); //参数nMax的值传给成员变量m_nMax
virtual ~STUDENT();
void AddNewSubject(SUBJECT &szSub); //添加新课程
SUBJECT* GetSubject(int nIndex); //获取指定编号的课程
int GetSubjectCount(); //获取当前课程数目
private:
int m_nSubjectCount; //当前课程数目
int m_nMax; //最大课程数目
SUBJECT* pSubject; //课程结构体指针
SUBJECT* buffer;
};
STUDENT::STUDENT(int nMax)
{
m_nMax=nMax;;
buffer=new SUBJECT[m_nMax];
if(buffer!=NULL)
{
pSubject=buffer;
}
else
{
exit(1);
}
cout<<"栈空间已成功建立!"<<endl;
}
STUDENT::~STUDENT()
{
delete []pSubject;
cout<<"内存清理完毕!"<<endl;
}
void STUDENT::AddNewSubject(SUBJECT &szSub)
{
cout<<"请输入课程名称)"<<"szSub.name"<<endl;
cout<<"请输入课程名称)"<<"szSub.level"<<endl;
//int i=m_nSubjectCount;
while(szSub.level != 0)
{
cout<<"请输入课程名称)"<<"szSub.name"<<endl;
cout<<"请输入课程名称)"<<"szSub.level"<<endl;
SUBJECT* pSubject=&szSub;
//i++;
}
}
SUBJECT*STUDENT::GetSubject(int nIndex)
{
cout<<"请输入要查找的课程编号!"<<endl;
cin>> nIndex;
if(nIndex<=m_nSubjectCount)
{
return &pSubject[nIndex];
}
else
{
cout<<"输入的课程编号错误,请重新输入!"<<endl;
return NULL;
}
}
int STUDENT::GetSubjectCount()
{
//cout<<"当前课程数目为:"<<endl;
return m_nSubjectCount;
}
int main(void)
{
SUBJECT sub[2]={"大学物理",12053,"大学英语",12054};
STUDENT(10);
GetSubject(1);
return 0;
}
其中关于GetSubject(1);的调用怎么调用啊