문자열 입력 받는 부분에서 터지는것 같은데.. 왜 터지는지 모르겠습니다..
// test.cpp : 콘솔 응용 프로그램에 대한 진입점을 정의합니다.
//
#include "stdafx.h"
class C_STUDENT
{
private:
int m_nId;
int m_nScore;
char *m_szName;
public:
C_STUDENT();
void createBuffer(int nSize);
void setnId (int nId);
void setnScore (int nScore);
void setszName (char * szName);
void setData (int nId, int nScore, char * szName);
int getnId();
int getnScore();
char getszName();
};
int _tmain(int argc, _TCHAR* argv[])
{
C_STUDENT cStudent;
cStudent.createBuffer(64);
cStudent.setnId(1);
cStudent.setnScore(20);
cStudent.setszName("김철수");
printf("%d\n",cStudent.getnId());
printf("%d\n",cStudent.getnScore());
printf("%s\n",cStudent.getszName());
return 0;
}
C_STUDENT::C_STUDENT ()
:m_nId(0),
m_nScore(0),
m_szName(NULL)
{
}
void C_STUDENT::createBuffer(int nSize)
{
m_szName = new char (nSize);
}
void C_STUDENT::setnId (int nId)
{
m_nId = nId;
}
void C_STUDENT::setnScore (int nScore)
{
m_nScore = nScore;
}
void C_STUDENT::setszName (char * szName)
{
m_szName = szName;
}
void C_STUDENT::setData (int nId,int nScore,char * szName)
{
m_nId = nId;
m_nScore = nScore;
m_szName = szName;
}
int C_STUDENT::getnId()
{
return m_nId;
}
int C_STUDENT::getnScore()
{
return m_nScore;
}
char C_STUDENT::getszName()
{
return *m_szName;
}