|
#include <iostream.h>
#include <conio.h>
int main(int argc, char* argv[])
{
const int cValue = 100;
// cValue = 200; 오류겠지요? 위에서 const int 로 선언했으니
// 100이라는 값을 바꿀수 없겠지요.
int Value_1 = 300;
int Value_2 = 400;
int * const pValue_1 = &Value_1;
*pValue_1 = 200;
// pValue_1 = &Value_2; 오류겠지요? 위에서 int * const 로 선언했으니
// 저장하는 변수의 주소는 바꿀수없겠지요
// 단 주소에 저장된 변수의 값은 바꿀수도 있겠지요
const int *pValue_2 = &Value_2; //100;
// *pValue_2 = 200; // 오류겠지요? 위에서 const int * 로 선언했으니
// 주소에 저장된 변수의 값은 바꿀수 있지만
// 저장하는 변수의 주소는 바꿀수 없겠지요
pValue_2 = &Value_1;
// 원하는 값을 출력하여 봅시다.
// cout - 콘솔에 out 합니다.
// << - 출력 스트림으로의 데이타를 보냅니다.
// endl - End line 으로 한줄 내려줍니다.
cout << "pValue_1 : " << pValue_1 << endl;
cout << "pValue_2 : " << pValue_2 << endl;
cout << "Value_1 : " << Value_1 << endl;
cout << "Value_2 : " << Value_2 << endl;
// cout << "*Value_1 : " << *Value_1 << endl;
// 요건 공부하시는 셈 치고 한번 해보세요.. 후후.. 그럼 ..
// cout << "*Value_2 : " << *Value_2 << endl;
cout << "&Value_1 : " << &Value_1 << endl;
cout << "&Value_2 : " << &Value_2 << endl;
getch();
return 0;
}
//---------------------------------------------------------------------------
|