摘要:
如果在变量申明语句中使用了限定符const, 那么变量在程序执行期间将不能被改变。const double version = 3.2;const 常见用途:1. 定义const指针,防止函数中修改由指针参数所指向的变量。#include <iostream>using namespace std;void printStr(const char *str){ //使用const来确保函数不能修改str所指向对象. while(*str){ //*str=*str+1; //错误,不能修改参数指向的对象。 cout<<(char)*str; str++; }}int m 阅读全文
posted @ 2012-05-28 10:56
fdyang
阅读(374)
评论(0)
推荐(0)

浙公网安备 33010602011771号