标签:
用Xcode来写C++程序[3] Constants
以下是一些基本数据的含义:
75 // int
75u // unsigned int
75l // long
75ul // unsigned long
75lu // unsigned long
3.14159 // 3.14159
6.02e23 // 6.02 x 10^23
1.6e-19 // 1.6 x 10^-19
3.0 // 3.0
3.14159L // long double
6.02e23f // float
‘z‘
// 单个字符
"How do you do?"
// 字符串
一些符号的含义:
bool类型以及指针
bool foo = true;
bool bar = false;
int* p = nullptr;
const变量
#include <iostream> using namespace std; const double pi = 3.14159; const char newline = ‘\n‘; int main () { double r=5.0; // radius double circle; circle = 2 * pi * r; cout << circle; cout << newline;
宏定义:
#include <iostream> using namespace std; #define PI 3.14159 #define NEWLINE ‘\n‘ int main () { double r=5.0; // radius double circle; circle = 2 * PI * r; cout << circle; cout << NEWLINE; }
[C++] 用Xcode来写C++程序[3] Constants
标签:
原文地址:http://www.cnblogs.com/YouXianMing/p/4316667.html