
C++笔记
记录C++学习过程的一些难点重点知识以及遇到的一些问题的解决办法
snowfly96
这个作者很懒,什么都没留下…
展开
-
关于动态变量new操作
关于动态变量new操作笔记 2018-12-4 内存分配定义指针变量 int *p;申请动态空间 new int;/new int[10];回收空间 delete p;/delete [] p; 申请空间new 操作在内存里像heap申请一块空间,操作的结果是这个空间的首地址new int[10];在heap里面申请一块连续的空间存放int类型数组;操作结果是这块空间的首地址;...原创 2018-12-04 22:42:38 · 553 阅读 · 0 评论 -
二叉查找树的简单实现
二叉查找树的简单实现笔记(2018-11-25)#include <iostream>#include <cstdlib>#include <ctime>using namespace std;struct node{ int value; node *left,*right; node(const int &x,n...原创 2018-11-25 17:03:04 · 147 阅读 · 0 评论 -
优先队列简单实现
优先队列简单实现笔记(2018-11-25)#include <iostream>#include <cstdlib>#include <ctime>#define mx 1000using namespace std;int elem[mx],len=0;void preDown(int hole){ int child; i...原创 2018-11-25 17:31:30 · 246 阅读 · 0 评论 -
函数指针以及类型内存大小
函数指针以及类型内存大小笔记 (2018-11-28)#include <iostream>using namespace std;void test1(){cout<<"test1 ";}//函数名test1就是地址void test2(){cout<<"test2 ";}void test3(){cout<<"test3 &原创 2018-11-29 16:01:27 · 2561 阅读 · 0 评论 -
非成员函数不能使用cv限定符
非成员函数不能使用cv限定符cv限定符:cv是const和volatile的首字母缩写node *find(const int &amp;x,node *t)const { if(t-&gt;value==x) return t; else if(t-&gt;value&gt;x) return find(x,t-&gt;left); else return find(...原创 2018-11-25 16:55:34 · 2019 阅读 · 0 评论 -
C++的try_catch_noexpect
C++ 的 try/catch/noexcept1.try_catchtry{ 可能会出现异常的语句}catch(…){ 对异常进行处理}2.noexcept 如果被noexcept修饰的函数抛出了异常,编译器直接选择调用标准库里面的std::terminate()直接终止程序,比throw()在处理异常的效率要高些有效的防治了异常的扩散传播...原创 2019-03-06 10:53:48 · 960 阅读 · 0 评论 -
C++ using的使用
C++ using 的使用1.命名空间 using namespace std;2.子类中引用基类成员class Base{ protected: int value; public: void print(){cout<<"hello world";}};class Inherit:private Base{ public...原创 2019-03-06 10:20:51 · 334 阅读 · 0 评论 -
return this与return*this的区别
return this 与return *this区别this指的是当前对象的指针,保存当前对象的地址*this指的是当前对象1.return this返回的是当前对象的地址2.如果返回对象为类型A,则return *this返回的是当前对象的一个克隆,保存在与当前对象的不同地址空间里;如果返回对象为类型A,则return *this返回的是当前对象;...原创 2019-03-31 22:21:45 · 432 阅读 · 0 评论