帮忙看看我的vc++小程序

来源:百度知道 编辑:UC知道 时间:2024/06/25 01:11:21
class score
{
public:
score(char*);

char* m_pszKemu;
int m_nScore;
};
class stu
{
public:
stu(char*);
score* m_pMathScore;
score* m_pEnglishScore;
score* m_pLitScore;

private:
char* m_pszStuNam;
float m_fAver;
//int m_nRaw;

public:
float getAverage();
void printScore(score*);
};

#include<iostream.h>
#include<afx.h>
#include"student.h"

float stu::getAverage()
{
float aver=(float)(m_pMathScore->m_nScore+m_pEnglishScore->m_nScore
+m_pLitScore->m_nScore)/3;
m_fAver= aver;
cout<<m_pszStuNam<<"的平均成绩是"<<m_fAver<<"分。"<<endl;

return m_fAver;
}

void stu::printScore(score* pScore)
{
cout<<m_pszStuNam<<"的"<<pScore->m_pszKemu<<"成绩是:"<<

void main()
{
stu stu1("李海燕");
stu1.printScore(stu1.m_pLitScore);
stu1.printScore(stu1.m_pMathScore);
stu1.printScore(stu1.m_pEnglishScore);
stu1.getAverage();
}
就你编译来看是主函数里面的问题,但我提醒LZ一句,你用的指针都new了没有,如果没有肯定还会有意想不到的问题,即使编译通过也可能运行中断。