헤더파일에서 함수가 아래와같이 되어 있습니다. 함수 앞은 반환타입인걸 알겠는데, 함수 뒤에 const는 어떤역할을 하나요?
bool abc() const {return true;}
this 포인터가 const라는 뜻입니다
어떤 클래스의 instance가 const 로 선언되었을 때, 호출될 수 있는 멤버 함수라는 뜻입니다.
class Something { ... public: void set_value(int value) {...} int get_value() const {...} } ... const Something s; ... int value = s.get_value(); // OK s.set_value(10); // compile error
텍스트 포맷에 대한 자세한 정보
<code>
<blockcode>
<apache>
<applescript>
<autoconf>
<awk>
<bash>
<c>
<cpp>
<css>
<diff>
<drupal5>
<drupal6>
<gdb>
<html>
<html5>
<java>
<javascript>
<ldif>
<lua>
<make>
<mysql>
<perl>
<perl6>
<php>
<pgsql>
<proftpd>
<python>
<reg>
<spec>
<ruby>
<foo>
[foo]
this 포인터가 const라는 뜻입니다
this 포인터가 const라는 뜻입니다
어떤 클래스의 instance가 const 로
어떤 클래스의 instance가 const 로 선언되었을 때, 호출될 수 있는 멤버 함수라는 뜻입니다.
댓글 달기