随笔分类 -  C++学习

摘要:If constructors were inherited in C++, it would cause many undesirable problems, and the main benefit of inheritance of members would not apply to con 阅读全文
posted @ 2017-09-03 12:08 Key_Ky 阅读(2315) 评论(0) 推荐(0)
摘要:上面的例子主要是想知道B,C是否会有自己的虚表指针,结果我用gdb -g test.cpp进行调试,发现: p a -> {_vptr.A = 0x400c28 <vtable for A+16>, i = 4197277} p b -> {<A> = {_vptr.A = 0x400c10 <vt 阅读全文
posted @ 2017-06-04 21:17 Key_Ky 阅读(304) 评论(0) 推荐(0)
摘要:直接看例子就好: Note keyword virtual here. virtual inheritance. virtual not needed here. It is necessary to initialize all virtual base classes explicitly in 阅读全文
posted @ 2017-06-04 19:31 Key_Ky 阅读(395) 评论(0) 推荐(0)
摘要:Token-Pasting Operator (##)The double-number-sign or “token-pasting” operator (##), which is sometimes called the “merging” operator, is used in both 阅读全文
posted @ 2017-01-22 22:33 Key_Ky 阅读(370) 评论(0) 推荐(0)
摘要:int j = 0;int &i = j++; //出错临时变量j++被引用i所绑定,出错。 阅读全文
posted @ 2014-12-28 10:21 Key_Ky 阅读(467) 评论(0) 推荐(0)
摘要:参考:http://blog.sina.com.cn/s/blog_5c0172280100ut4o.html1、char *s="abc";看这个赋值:右边,是"abc",是个字符串常量,存在于内存某处(我的机器上是ds:0x0046f034),程序员不知道,编译器安排的,也没必要知道(当然,这个... 阅读全文
posted @ 2014-09-28 00:40 Key_Ky 阅读(709) 评论(0) 推荐(0)
摘要:#include "stdafx.h"#include #include using namespace std;//定义一个错误类class RangeException{public: const char* range_error; RangeException(const char* s):range_error(s){}};double Fuc(double x, double y){ if(y == 0){ throw RangeException("error of dividing zero.\n"); //抛出一个错误 } retu.. 阅读全文
posted @ 2014-01-27 20:22 Key_Ky 阅读(364) 评论(0) 推荐(0)