c++ this pointer const 에 관한 내용
글쓴이: gyxor / 작성시간: 금, 2003/05/16 - 11:58오전
#include<iostream>
using namespace std;
class r
{
public :
int k;
void e() const //........(1)
{
(*this) = 199;
cout << "eee";
}
};
int main()
{
r w;
w.e();
return 0;
}위 예문에서 (1) 의 const는 호출객체의 내용을 수정하지 못하도록 만듭니다. (*this).멤버 = 수정 하려하면 에러인데요....
const int * p;
int *const p;
의미가 다르듯이 this or *this 중에 한가지만 고정하는것이 아닌가요?
사용되는것으로 봐서 this 는 고정이 아닌거 같은데요..
이 내용을 수정할수도 있는지요?
문법외적인 내용인거 같지만 궁금해서 질문드립니다.
답변부탁드립니다.
Forums:


http://www.parashift.com/c++-faq-lite/co
http://www.parashift.com/c++-faq-lite/const-correctness.html
댓글 달기