随笔分类 - C++Primer学习之路
摘要:#include #include #include #include using std::string; using std::cout; using std::cin; using std::endl; using std::vector; int main() { vector v; for (decltype(v.size()) i = 2; i < 10; +...
阅读全文
摘要:#include #include #include using std::string; using std::cout; using std::cin; using std::endl; int main() { string str{"hello world!!!"}; int count = 0; for ( decltype(str.size()) ind...
阅读全文
摘要:#include using namespace std; int main() { int i = 42, *p = &i, &r = i; decltype(r+1) b = 45; decltype(*p) c = i; cout using namespace std; int main() { int i = 42, *p = &i, &r =...
阅读全文
摘要:#include using namespace std; int main() { typedef char *pstring; typedef double that; char a = 'a'; that i = 2.3; pstring b = &a; cout using namespace std; int main() { ...
阅读全文
摘要:首先: 所以: * &在不同地方有不同的含义,不能一味地认为*是取所指对象,&也不是仅用于取地址,他们都是修饰符。 结果: 所以: *&r = p 相当于 *(&r) = p 从右往左看,r先跟&合并,表示“别名”,&r相当于一个变量,比如说就是rp, p的另一个名字叫&r,p的地址和r的地址是一样
阅读全文
摘要:1. 输出: 2. 输出: 会覆盖前面的值。 3. 输出同上: 4. 输出: 综上: \r : 会将指针重新回到句首,在没有遇到endl或者\n的时候不会将缓存显示在控制台上 \n 与endl : endl会刷新缓冲区
阅读全文
摘要://2019/03/04 #include int main() { int i{ 3 }; std::cout << i << std::endl; std::cout << 1E-3F << std::endl; system("pause"); return 0; }
阅读全文
摘要:结果: 4294967295 ?? 首先,仔细观察输出的结果4294967295,发现4294967295=2^32-1,哦!好像有点规律! 但是,又为啥会是这样? 让我们先来讨论下int和unsigned int的表现形式,他俩都是4个字节,32位的二进制表示,但int有一位是符号位,unsign
阅读全文
摘要:来源:http://www.cnblogs.com/zhangziqiu/archive/2011/03/30/computercode.html 本篇文章讲解了计算机的原码, 反码和补码. 并且进行了深入探求了为何要使用反码和补码, 以及更进一步的论证了为何可以用反码, 补码的加法计算原码的减法
阅读全文
摘要:使用hex和oct以上述三种格式显示十进制值42。默认格式为十进制,在修改格式之前,原来的格式将一直有效
阅读全文
摘要:signed char表示有符号字符,在-128~127之间; unsigned char 表示无符号字符,在0~255之间; 由于与ANSII对应: 也长这样: ANSII为0000 0000~0111 1111 共127个字符(unsigned char且<128) 绝大多数计算机的一个字节(b
阅读全文
摘要:输入:111 111 111 111 22 22 22 22 34 444 444 777 777 (回车) 得到: 还在等着键盘的输入。 原因:cin没有遇到end-of-file 输入:111 111 111 111 22 22 22 22 34 444 444 777 777 (ctrl +
阅读全文

浙公网安备 33010602011771号