【p7】使用什么扩展名取决于C++实现,例如spiffy.C是有效的Unix C++源代码文件,注意Unix区分大小写,这意味着信使用大写的C字母,事实上,小写c扩展名也是有效的,但标准C才使用小写的c,因此,为避免在Unix系统上发生混淆,对于C程序应使用c(小写)对于C++程序则使用C(大写)。如果不在乎多输入一两个字,则对某些Unix系统,也可以使用扩展名cc和cxx。DOS比Unix稍微简单一点,不区分大小写,因此dos实现使用额外的字母来区分C和C++程序。如下表:
微信图片_20200108082804.jpg
【p38】以两个下划线或下划线和大写字母打头的名称被保留给系统实现(编译器及其使用的资源)使用,一个下划线开头的名称被保留给实现,用作全局标识。
int my_stars3; //valid
int _My_stars3; //valid but reserved
int __fools; //two underlines------valid but reserved
【p40】short是short int的简称,long是long int 的简称。头文件climits中包含了整型的限制信息。
【p41】对类型名(如int)使用sizeof云算符时,应将名称放在括号内;但对于变量名(如n_short)使用该 预算符,括号是可选的。
/******************
* 3.1 limits.cpp
*****************/
#include <iostream>
#include <climits>
using namespace std;
int main() {
int n_int = INT_MAX;
short n_short = SHRT_MAX;
long n_long = LONG_MAX;
long long n_llong = LLONG_MAX;
cout << "int is " << sizeof(int)<< " bytes." << endl; //() is need
cout << "int is " << sizeof n_short << " bytes." << endl; //not ()
cout << "int is " << sizeof n_long << " bytes." << endl;
cout << "int is " << sizeof n_llong << " bytes." << endl;
return 0; //return 0
}
运行结果:
int is 4 bytes.
int is 2 bytes.
int is 4 bytes.
int is 8 bytes.
Process returned 0 (0x0) execution time : 0.568 s
Press any key to continue.
【p42】有些头文件,尤其是那些被设计可用于C和C++的头文件,必须使用#define。(const和define声申明符合常量)
【p55】如果读者在学习C++之前学过C语言,并打算使用define来定义符号常量,请不要这样做,而应使用const。









网友评论