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;
}
广告
数据结构
网络
关系型数据库管理系统
操作系统
Java
iOS
HTML
CSS
Android
Python
C 编程
C++
C#
MongoDB
MySQL
Javascript
PHP