上一页 1 ··· 3 4 5 6 7
摘要: C++ 类:实体的抽象类型 实体(属性,行为) ->ADT(abstract data type) 类(属性->成员变量,行为->成员方法) OOP语言4大特征 抽象 封装/隐藏(通过public private protected) 继承 多态 class Student{ //属性一般都是私有的 阅读全文
posted @ 2022-11-06 22:14 Hello_Bugs 阅读(76) 评论(0) 推荐(0) 编辑
摘要: new和malloc区别?delete和free区别? malloc和free是C语言的库函数 new和delete叫做运算符 malloc是否开辟成功是通过返回值和空指针比对判断.而new开辟失败会抛出异常 bad_alloc new 不仅可以做内存开辟,还可以做内存初始化操作. int *p = 阅读全文
posted @ 2022-11-02 09:50 Hello_Bugs 阅读(86) 评论(0) 推荐(0) 编辑
摘要: 1:C++的引用,引用和指针的区别? 1:从汇编指令角度上看,引用和指针没有区别,引用也是通过地址指针的方式访问指向的内存 int &b=a ; 是需要将a的内存地址取出并存下来, b=20;(通过引用修改值时,也是先取出指向的地址,然后访问该地址的值并修改它,和通过指针修改值一样) 在定义引用的时 阅读全文
posted @ 2022-10-28 22:13 Hello_Bugs 阅读(114) 评论(0) 推荐(0) 编辑
摘要: C++中 Const修饰的量叫常量,与普通变量的区别是什么? C++中有两点 1:编译方式不同,在编译的过程中,所有在程序中出现名字的地方都会被初值替换掉 2:不能作为左值了 const修饰的量常出现的使用错误有 1:常量作为左值修改值 (因为这种方式可以直接修改常量的值) 2:把常量的地址泄漏给一 阅读全文
posted @ 2022-10-28 16:22 Hello_Bugs 阅读(84) 评论(0) 推荐(0) 编辑
摘要: const怎么理解? const修饰的变量不能够在作为左值!!初始化完成后,值不能被修改!! C 和C++中const 的区别? 在C程序中 test.c const int a; 只定义,不做初始化(C中允许),如果不做初始化,那么后面就不能再赋值了. 在C语言中const修饰的量,可以不用初始化 阅读全文
posted @ 2022-10-28 11:30 Hello_Bugs 阅读(130) 评论(0) 推荐(0) 编辑
摘要: C++函数重载代码如下 #include <iostream> using namespace std; bool compare(int a,int b){ cout<<"compare_int_int"<<endl; return a>b; } bool compare(){ cout<<"co 阅读全文
posted @ 2022-10-26 12:17 Hello_Bugs 阅读(132) 评论(0) 推荐(0) 编辑
摘要: 如下代码 using namespace std; int sum(int a,int b){ return a + b; } int main(){ int a =1; int b =2; int ret =sum(a,b); return 0; } 上面sum函数调用,会涉及到参数压栈,函数栈帧 阅读全文
posted @ 2022-10-13 15:59 Hello_Bugs 阅读(99) 评论(0) 推荐(0) 编辑
摘要: 下面代码中备注部分为 从汇编指令角度 看形参带默认值得函数调用 #include <iostream> using namespace std; int sum(int a=10,int b=20){ return a + b; } int main(){ int a =1; int b =2; / 阅读全文
posted @ 2022-10-12 14:13 Hello_Bugs 阅读(67) 评论(0) 推荐(0) 编辑
摘要: 代码1 **sum.cpp** int gdata=10; int sum(int a,int b){ return a+b; } **main.cpp** extern int gdata; int sum(int , int ); int data=20; int main(){ int a = 阅读全文
posted @ 2022-10-12 09:27 Hello_Bugs 阅读(178) 评论(0) 推荐(0) 编辑
摘要: 程序与进程的区别 程序: 静态 预先编译好的指令和数据的集合 的一个文件 #菜谱 进程: 动态 程序运行的过程 #炒菜的过程 虚拟地址空间: 程序运行后拥有自己独立的虚拟空间 大小: CPU位数决定 指针大小与虚拟地址空间位数相同 32 位平台 *p 32位==4byte 64位 *p 64位 == 阅读全文
posted @ 2022-10-11 20:05 Hello_Bugs 阅读(347) 评论(0) 推荐(0) 编辑
上一页 1 ··· 3 4 5 6 7