
C++
wujinggrt
努力学习中。
展开
-
C++中函数的Named Return Value优化理解
#include <iostream>using namespace std;class Hehe { public: Hehe() : i(0) { cout << "ctr" << __LINE__ << endl;} ~Hehe() { cout << "dctr" << _原创 2018-08-18 18:43:13 · 1019 阅读 · 0 评论 -
C++类内初始值(C++11)与构造函数初始值列表的关系
#include <iostream>using namespace std;int g_count = 0;struct Data{ Data(int i = 0) { cout << "Data ctor: param: i: " << i << endl; } Data(cons...原创 2018-09-04 23:01:32 · 2630 阅读 · 0 评论 -
C++有/无符号数字类型之间的比较
在kmp.cpp中的循环,循环判断下标(int类型)与std::string::size_type类型比较发生了循环只执行一部分的问题。int i = j = 0while (i < s.size() && j < p.size()){// some codes may make j -1;} 在这段代码当中,出现了j < p.size()但...原创 2018-09-22 12:46:45 · 1234 阅读 · 0 评论 -
Ubuntu 19.04 安装 cgdb 时 ./autogen.sh 的错误
根据 http://cgdb.github.io 的操作,在 ./autogen.sh 这一步的时候出现了各种错误,参考了博主 analogous_love 的文章,基本解决了出现的问题。但是安装 readline-dev 这一步一直不能够搞定。报错如下:在寻找安装 readline-dev 遇到这个地方 https://www.howtoinstall.co/en/ubuntu/xenial...原创 2019-09-14 23:46:48 · 346 阅读 · 0 评论 -
C++:不要返回局部作用域内的引用,即使右值引用也不能延长它的生命周期
此文章首发于本人知乎https://zhuanlan.zhihu.com/p/81547559。struct A { A() : log{"default"} { cout << "A\n"; } A(const A&) : log{"copy"} { cout << "A&\n"; } A(A&&) : log{"move"}...原创 2019-09-14 23:54:13 · 1068 阅读 · 1 评论