关于类的问题 这是出了什么问题啊?
#ifndef __CSTU_H__#define __CSTU_H__
class CStu
{
protected:
char m_No[11];
char m_Name[11];
unsigned short m_Age;
char m_Sex[3];
char *m_Rem;
unsigned int m_RemBytes;
public:
void Show();
unsigned int GetRemBytes();
bool SetNo(char *No);
char *GetNo();
bool SetName(char *Name);
char *GetName();
bool SetAge(unsigned short Age);
unsigned short GetAge();
bool SetRem(char *Rem);
char *GetRem();
bool SetSex(char *Sex);
char *GetSex();
CStu(const CStu &s);
};
#endif
#include"StdAfx.h"
#include <iostream>
#include <string>
#include "CStu.h"
using namespace std;
void CStu::Show()
{
cout<<"学号:"<<m_No<<endl;
cout<<"姓名:"<<m_Name<<endl;
cout<<"性别:"<<m_Sex<<endl;
cout<<"年龄:"<<m_Age<<endl;
cout<<"简历:"<<m_Rem<<endl;
}
unsigned int CStu::GetRemBytes()
{
return m_RemBytes;
}
bool CStu::SetNo(char *No)
{
if(strlen(No)!=10 )
return false;
else
strcpy(m_No,No);
return true;
}
char * CStu::GetNo()
{
return m_No;
}
bool CStu::SetName(char *Name)
{
if(strlen(Name)>=10 )
return false;
else
strcpy(m_Name,Name);
return true;
}
char * CStu::GetName()
{
return m_Name;
}
bool CStu::SetAge(unsigned short Age)
{
if(Age>=60)
return false;
else
m_Age=Age;
return true;
}
unsigned short CStu::GetAge()
{
return m_Age;
}
bool CStu::SetRem(char *Rem)
{
int Len=strlen(Rem);
char *p=new char[Len+1];
if(p==NULL)
return false;
if(m_Rem!=NULL)
delete []m_Rem;
m_RemBytes=Len;
m_Rem=p;
strcpy(m_Rem,Rem);
return true;
}
char * CStu::GetRem()
{
return m_Rem;
}
bool CStu::SetSex(char *Sex)
{
if(strcmp("男",Sex)==0 || strcmp("女",Sex)==0)
{
strcpy(m_Sex,Sex);
return true;
}
else
return false;
}
char *CStu::GetSex()
{
return m_Sex;
};
CStu::CStu(const CStu &s)
{
strcpy(m_No,s.m_No);
strcpy(m_Name,s.m_Name);
strcpy(m_Sex,s.m_Sex);
m_Age=s.m_Age;
if(s.m_Rem!=NULL)
{
m_RemBytes=s.m_RemBytes;
m_Rem=new char[m_RemBytes+1];
strcpy(m_Rem,s.m_Rem);
}
else
{
m_Rem=NULL;
m_RemBytes=0;
}
cout<<调用了复制函数<<end1;
}
#include"StdAfx.h"
#include <iostream>
#include <string>
#include "CStu.h"
using namespace std;
void main ()
{
CStu s1("3110413030");
s1.Show();
}
运行时提示 fatal error C1083: Cannot open precompiled header file: 'Debug/MY.pch': No such file or directory
并且总是提示STDAFX.H 出错啊