|
김상면 님이 쓰신 글 :
: 생성자에서 아래와 같은 코딩은 어떤 의미인가요
: this = malloc(.....)
:
: 정말 C++어렵습니다. 산넘어 산이군요
: 그럼
클래스 안에서 객체의 주소를 가지는 this 포인터는 lvalue가 될 수 없습니다.
아마도 잘못된 코드같습니다.
[ISO/IEC 14882-1998 Programming Language C++]
9.3.2 The this pointer
1 In the body of a nonstatic (9.3) member function, the keyword this is
a nonlvalue expression whose value is the address of the object for
which the function is called. The type of this in a member function
of a class X is X*. If the member function is declared const,
the type of this is const X*, if the member function is declared volatile,
the type of this is volatile X*, and if the member function is declared
const volatile, the type of this is const volatile X*.
c++에서 객체에 생성은 new 연산자를 통해 합니다.
malloc은 C 기반 라이브러리로 객체에 생성에 사용하면 어떠한 문제점이 있다고 하던데.. .잊어버렸습니다. =ㅈ=;
|