복사생성자질문...

프로그래밍 일반에 관한 포럼입니다.

Moderator: 류광

Locked
비회원

복사생성자질문...

Post by 비회원 »

아래 같은경우에는 복사생성자를 어떻게 해야할지.. 막막하네요...ㅠ.ㅠ

도움 부탁드립니다.

----------------------------------------------------------------------------------
CCatchPoint::CCatchPoint(char *openFileName,int tLine)
{
char charac='0';

FILE *file;
iTotalLine = tLine;

//File Open
if((file = fopen(openFileName,"rt"))==NULL)
{
printf("Error:Can not File open!");
return;
}//if

//동적배열할당
if(!(pBuf = new char[iTotalLine*MAX_LENGTH])) { printf("Error:pBuf"); };
if(!(m_X = new double[iTotalLine])) { printf("Error:m_X"); }
if(!(m_Y = new double[iTotalLine])) { printf("Error:m_Y"); }
if(!(m_Z = new double[iTotalLine])) { printf("Error:m_Z"); }
if(!(m_H = new double[iTotalLine])) { printf("Error:m_H"); }
if(!(m_P = new double[iTotalLine])) { printf("Error:m_P"); }
if(!(m_R = new double[iTotalLine])) { printf("Error:m_R"); }
if(!(imsi = new double[iTotalLine * 6])) { printf("Error:imsi"); }
if(!(token = new char[20])) { printf("Error:token"); }
if(!(lineBuf = new char[MAX_LENGTH])) { printf("Error:lineBuf"); }


//////////////////////////////////////
length = _filelength(fileno(file));
//////////////////////////////////////
memset(pBuf,0, length);
fread(pBuf,1, length, file);


fclose(file);

posTok();

}
imays
Posts: 1044
Joined: 2003-02-18 10:29
Contact:

조언

Post by imays »

사본의 CCatchPoint의 멤버 변수들은 원본의 멤버 변수들을 복사하나요 참조하나요?

꼭 전체의 사본이 필요한게 아니면 CCatchPoint를 그냥 스마트 포인터로 접근하는 객체로 만드심이 better.
온라인 게임 서버 엔진 ProudNet
http://www.nettention.com
Locked