会员
众包
新闻
博问
闪存
赞助商
HarmonyOS
Chat2DB
所有博客
当前博客
我的博客
我的园子
账号设置
会员中心
简洁模式
...
退出登录
注册
登录
ericshi1985
博客园
首页
新随笔
联系
订阅
管理
上一页
1
2
3
4
5
6
7
下一页
2022年12月2日
<一>智能指针之__智能指针基础
摘要: 代码1 int main(){ //裸指针,手动开辟,需要自己释放,如果忘记了或者因为 //程序逻辑导致p没有释放,那么就会导致内存泄漏 int *p=new int(10); if(***){ retur -1; } delete p; return 0; } 有没有什么办法帮我们管理指针,确保资
阅读全文
posted @ 2022-12-02 15:19 Hello_Bugs
阅读(104)
评论(0)
推荐(0)
2022年12月1日
<三>关于对象优化
摘要: 代码1 #include <iostream> #include <functional> #include<cstdio> #include<cstring> using namespace std; class MyString3 { public: MyString3(const char *
阅读全文
posted @ 2022-12-01 17:28 Hello_Bugs
阅读(63)
评论(0)
推荐(0)
<二>函数调用过程中对象优化
摘要: 代码1 using namespace std; class TestV2 { public: TestV2(int a = 10) : ma(a) { cout << "TestV2(int) " << ma <<" 对象地址="<<this << endl; } ~TestV2() { cout
阅读全文
posted @ 2022-12-01 12:11 Hello_Bugs
阅读(62)
评论(0)
推荐(0)
<一>对象使用过程中背后调用了哪些方法
摘要: 代码1 #include <iostream> using namepspace std; class Test { public: Test(int a=10):ma(a){cout<<"Test()"<<endl;} ~Test(){cout<<"~Test()"<<endl;} Test(co
阅读全文
posted @ 2022-12-01 09:55 Hello_Bugs
阅读(66)
评论(0)
推荐(0)
2022年11月30日
<十>C++的四种类型转换
摘要: C语言中我们使用 int a=(int) b;的方式强制转换 C++提供了四种类型转换方式 const_cast 通过const_cast运算符,也只能将const type转换为type,将const type&转换为type&。 也就是说源类型和目标类型除了const属性不同,其他地方完全相同
阅读全文
posted @ 2022-11-30 10:22 Hello_Bugs
阅读(170)
评论(0)
推荐(0)
2022年11月29日
<十>关于菱形继承
摘要: 代码1 #include <iostream> using namespace std; class A{ public: A(int _a):ma(_a){ cout<<"A()"<<endl; } ~A(){ cout<<"~A()"<<endl; } protected: int ma; };
阅读全文
posted @ 2022-11-29 21:51 Hello_Bugs
阅读(86)
评论(0)
推荐(0)
<九>理解虚继承和虚基类
摘要: 虚基类/抽象类 抽象类:有纯虚函数的类 代码1 class A{ public: int ma; protcted: int mb; private: int mc; } //B继承 A, class B : public A{ public: int md; potected: int me; p
阅读全文
posted @ 2022-11-29 15:16 Hello_Bugs
阅读(177)
评论(0)
推荐(0)
2022年11月28日
<七>理解多态
摘要: 理解多态 多种多样的形态(静态多态,动态多态) 静态多态(编译时期) 1:函数重载 bool comparet(int ,int); bool compare(double,double); compare(100,100)->compare_int_int(); compare(1.0,2.0)-
阅读全文
posted @ 2022-11-28 15:15 Hello_Bugs
阅读(73)
评论(0)
推荐(0)
<八>理解抽象类
摘要: 抽象类和普通类有什么区别? 抽象类一般不用作抽象实体类型 一般把上面类设计为抽象类? 基类 定义抽象类的唯一目的, 就是去建立派生类. 我们在抽象类基础上要定义出功能各异的派生类, 再用这些派生类去建立对象. 凡是包含纯虚函数的类都是抽象类. 纯虚函数不用实现, 故不能被调用, 抽象类无法建立对象.
阅读全文
posted @ 2022-11-28 14:06 Hello_Bugs
阅读(94)
评论(0)
推荐(0)
<六>关于虚函数和动态绑定
摘要: 问题:是不是虚函数的调用就一定是动态绑定?不是的 1:在类的构造函数当中,调用虚函数,也是静态绑定(构造函数中对虚函数的调用不发生动态绑定) 2:如果不是通过指针或者引用变量来调用虚函数,那就是静态绑定 代码1 class Base { public: Base(int data=10):ma(da
阅读全文
posted @ 2022-11-28 11:13 Hello_Bugs
阅读(115)
评论(0)
推荐(0)
上一页
1
2
3
4
5
6
7
下一页
公告