C++ 中有哪些不同的常量类型?
C++ 中没有常量类型。只是你可以将 C++ 中的任何数据类型声明为常量。如果使用 const 关键字将变量声明为常量,则你无法重新赋值。
示例
#include<iostream>
using namespace std;
int main() {
const int i = 5;
// Now all of these operations are illegal and
// will cause an error:
i = 10;
i *= 2;
i++;
i--;
//...
return 0;
}
广告
数据结构
网络
RDBMS
操作系统
Java
iOS
HTML
CSS
Android
Python
C 编程
C++
C#
MongoDB
MySQL
Javascript
PHP