일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 | 29 | 30 | 31 |
Tags
- python
- if
- ubuntu
- expect
- ngui
- pi
- postgresql
- DROP
- Shader
- Unity
- conda
- 쉘
- FIND
- with
- C++
- mysql
- SSH
- autovacuum
- c++11
- awk
- Eclipse
- sqlite
- dataframe
- List
- pandas
- null
- sql
- boost
- SVN
- 배열
Archives
- Today
- Total
その先にあるもの…
[C++]const_cast 본문
형을 변환 시켜주는 것이 아니라
const, 참조를 제거한다.
char str[] = "BitCoin";
const char* ptr = str;
cout << " before : " << str << endl; (before : BitCoin)
//str[0] = 'b'; //error
char* remove_const = const_cast<char*>(ptr);
remove_const[0] = 'b';
cout << " after 0: " << str << endl; (after 0 : bitCoin)
remove_const[0] = 'B';
cout << " after 1: " << str << endl; (after 1 : BitCoin)
const int value = 10;
const int& ref = value;
int& ref2 = const_cast<int&>(ref);
ref2 = 20;
cout << "value(" << value << ") " << " ref(" << ref << ") " << " ref2(" << ref2 << ")" << endl;
Value(10) ref(20) ref2(20)
'프로그래밍' 카테고리의 다른 글
정규표현식 정리 (0) | 2019.09.18 |
---|---|
[C++] dynamic_cast (0) | 2018.12.12 |
[C++]LNK2019 (0) | 2018.10.19 |
[SHELL SCRIPT] 쉘스크립트IF (0) | 2018.03.29 |
[SHELL SCRIPT] 쉘 스크립트 scp 예제 (0) | 2018.03.29 |
Comments