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