摘要: 下面代码侧面说明,编译器在构造函数末尾处初始化vptr。所以如果在构造函数中调用virtual函数,动态绑定不会起作用,只会调用本类中的virtual函数: 下面代码是我自己写的读取虚函数表示例: 屏幕输出: 如果将 改为 class Base{ public: virtual void func0 阅读全文
posted @ 2018-12-13 20:45 super行者 阅读(190) 评论(0) 推荐(0) 编辑
摘要: #include #include using namespace std; class MyString { public: MyString(const char * s=NULL) { if (s == NULL) { m_string = new char[1]; m_string[... 阅读全文
posted @ 2018-12-13 06:24 super行者 阅读(542) 评论(0) 推荐(0) 编辑
摘要: [转自]https://blog.csdn.net/geophyboy/article/details/14119775 问题(知识点)描述:a. 在C++的类的成员函数中,允许直接访问该类的对象的私有成员变量。b. 在类的成员函数中可以访问同类型实例的私有变量。c. 拷贝构造函数里,可以直接访问另 阅读全文
posted @ 2018-12-13 05:40 super行者 阅读(1393) 评论(0) 推荐(0) 编辑