일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | ||||||
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 |
Tags
- C++
- 포인터
- Algorithm
- github
- HTML
- gitlab
- dart 언어
- C# delegate
- 깃
- c언어
- c# winform
- c# 윈폼
- jupyter lab
- c# 추상 클래스
- vim
- Houdini
- 도커
- C언어 포인터
- Python
- 플러터
- 구조체
- 다트 언어
- jupyter
- Data Structure
- Flutter
- 유니티
- Unity
- git
- docker
- c#
Archives
- Today
- Total
목록const 멤버 함수와 비 const 멤버 함수 (1)
nomad-programmer
[Programming/C++] const 멤버 함수와 비 const 멤버 함수
const 멤버 함수는 멤버 함수 내에서 객체의 멤버 변수를 변경하지 않는다는 것을 보장하는 함수이다. 따라서 const 객체는 const 멤버 함수만 호출할 수 있다. const 멤버 함수에서 멤버 변수를 변경하면 컴파일 에러가 발생한다. 사실 자신의 멤버를 변경하지 않는 멤버 함수는 모두 const 멤버 함수여야만 한다. 다음은 cosnt 멤버 함수 예제이다. class Point{ public: Point(int _x=0, int _y=0) : x(_x), y(_y) {} int GetX() const { return x; } int GetY() const { return y; } void SetX(int _x) { x = _x; } void SetY(int _y) { y = _y; } void P..
Programming/C++
2023. 1. 19. 15:47