const限定符最基本的

来源:互联网 发布:aloha什么软件 编辑:程序博客网 时间:2024/06/08 17:07
#include <iostream>#include <string>int main (){const int bufSize = 512; //缓冲区的大小 buffer size ,这里的bufSize永远是常量512,要是在其它地方声明必须在const前面加上extern再在下边的表示可以省去不写,为extern const int bufSize = 512; const std::string shi = "xiao cui";const int i = 2, j = 4;for(int index = 0; index != bufSize; ++index){std::cout << index << std::endl;}std::cout << shi << std::endl;std::cout << j << std::endl;return 0;}

0 0
原创粉丝点击