随笔分类 -  c++

摘要:一、先看下面两段完全一样的代码块 /* test.cpp */ int main() { int a = 5; ++a = 7; printf("%d\n", a); return 0; } /* test.c */ int main() { int a = 5; ++a = 7; printf(" 阅读全文
posted @ 2020-10-15 14:47 _程序兔 阅读(996) 评论(0) 推荐(0) 编辑
摘要:一、例子 template <typename T> inline void callWithMax(const T& a, const T& b){ f(a > b ? a : b); } int main(){ return 0; } 二、理解 关于函数模板的编译以及函数模板的实例化从这个例子可 阅读全文
posted @ 2020-07-13 10:22 _程序兔 阅读(444) 评论(1) 推荐(0) 编辑
摘要:一、前言 今天在看Thinking in C++这本书时,书中的一个例子引起了我的注意,具体是使用了下面这句 单看这条语句的语义会发现仅仅是使用一个简单的string的substr函数将所得子串push_back到strings。但是在阅读时我却对于substr的参数传递产生了疑惑,到底是先执行了+ 阅读全文
posted @ 2020-05-30 08:43 _程序兔 阅读(1676) 评论(0) 推荐(1) 编辑
摘要:程序如下,判断输出多少个'_' 【运行环境:Linux】 ./a.out int main(){ for(int i = 0; i < 2; ++i){ fork(); printf("_"); } } 熟悉fork的话,这里很容易就能知道,一共产生了3个子进程,还有一个父进程,所以一共是四个进程; 阅读全文
posted @ 2020-03-24 16:34 _程序兔 阅读(678) 评论(0) 推荐(2) 编辑
摘要:一、#define宏定义 如下程序段,则输出结果为: #define MAX 12 int main(){ cout << "20\0MAX019" << endl; } 输出结果:20 , 知识点:#define定义 的宏常量不替换程序中""里的东西 https://www.cnblogs.com 阅读全文
posted @ 2019-11-20 09:29 _程序兔 阅读(185) 评论(0) 推荐(0) 编辑
摘要:直接附链接; (非原创 非原创 非原创) https://blog.csdn.net/kbccs/article/details/80114971 阅读全文
posted @ 2019-10-19 22:10 _程序兔 阅读(2103) 评论(0) 推荐(0) 编辑
摘要:看一道C++面试题: 给出下述代码,分析编译运行的结果,并提供3个选项: A.编译错误 B.编译成功,运行时程序崩溃 C.编译运行正常,输出10 class A { private: int value; public: A(int n){ value = n;} A(A other){ value 阅读全文
posted @ 2019-09-10 22:02 _程序兔 阅读(2111) 评论(0) 推荐(0) 编辑

点击右上角即可分享
微信分享提示