⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 pointerassignment.cpp

📁 ThinkingC++中文版
💻 CPP
字号:
//: C08:PointerAssignment.cpp
// From Thinking in C++, 2nd Edition
// Available at http://www.BruceEckel.com
// (c) Bruce Eckel 2000
// Copyright notice in Copyright.txt
#include <iostream>
using namespace std;



void main()
{
   
	int d = 1;	
	int* u  ;
	const int e = 2;   //常量对象
	const int *pointer_const;	 //常量指针


	pointer_const = &d;	 //	 assign the address of a non-const object to a const pointer 
	pointer_const = &e;
	u = &d; // OK -- d not const
	//!u = &e;	   // Illegal -- e const


	int* w = (int*)&e; // Legal but bad practice
 	*w=4;	  //设置断点,发现e值已改变!
	cout<<"e="<<e<<endl;

} ///:~

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -