
C++primer笔记
Ziyang Luo
随缘
展开
-
char & unsigned char & signed char
一、开始今天有一个困扰的问题,就是char与signed char, unsigned char这三者的区别。二、三者之间1.ANSI C 提供了3种字符类型,分别是char、signed char、unsigned char。而不是像short、int一样只有两种(int默认就是unsigned int).2.三者都占1个字节3.signed char转载 2016-07-23 19:04:06 · 378 阅读 · 0 评论 -
Decide which type to use
1.use an unsigned type when you know that the values cannot be negative.2.use int for integer arithmatic. If the data is larger than the minimum guaranteed size of an int, that use long long3.Do n原创 2016-07-23 19:31:53 · 268 阅读 · 0 评论 -
An out-of-range value
1.If we assign an out-of-range value to an object of unsigned type, the result is the remainder of the modulo the number of values the target type can hold.2.If we assign an out-of-range value to an原创 2016-07-23 20:17:47 · 748 阅读 · 0 评论 -
Using file redirection
(Windows OS下) Example.cpp#includeusing namespace std;int main(){int a;cin>>a;cout<<a<<endl;return 0;}注意要在 .exe 文件目录下输入Example.exeoutfile.txt就可以了,>表示数据输出到outfile.txt原创 2016-07-16 20:44:24 · 254 阅读 · 0 评论 -
A pointer to an object & A pointer one past the end of a different object
In C++ primer, chapter 2, we can find this sentence "it is possible for a pointer to an object and a pointer one past the end of a different object to hold the same address."What exactally d原创 2016-08-10 21:31:48 · 635 阅读 · 0 评论 -
References to const
If we want to bind a reference to an object of a const type. To do so we must use a reference to const.const int a=1; const int &r=a;error: int &r1=a;const references is a reference to const? Techn原创 2016-08-11 19:38:30 · 323 阅读 · 0 评论