摘要: 指针: 1.指向对象的地址,所以sizeof永久只能取到4 2.声明时候开销4字节内存,但可以通过new等操作申请内存,delete释放内存,所以指针操作是内存访问/管理的最灵活方式 3.作为参数传递时候也会产生4字节临时开销 引用: 1.绑定了对象本身,只能初始化一次,所以sizeof只能取到对象 阅读全文
posted @ 2021-06-14 12:17 默*为 阅读(36) 评论(0) 推荐(0) 编辑
摘要: #include <iostream>#include <vector>using namespace std;int main(){ vector<int> bgX{ 5, 10 };//size=2,内容是5 ,10 vector<int> bgX1(5, 10);//size=5,内容是10, 阅读全文
posted @ 2021-06-06 17:43 默*为 阅读(77) 评论(0) 推荐(0) 编辑
摘要: #include <iostream>#include<string>#include <vector>#include <map>using namespace std; int main(){ vector<int> bgX{5, 10}; //方法1 bgX.erase(bgX.begin() 阅读全文
posted @ 2021-06-06 17:13 默*为 阅读(1013) 评论(0) 推荐(0) 编辑
摘要: 16:23:44/*1.基本类型 */ size_t len = sizeof(char);//1 len = sizeof(float);//4 len = sizeof(int);//4len = sizeof(long);//4len = sizeof(double);//8 /*2.容易误导 阅读全文
posted @ 2021-06-06 16:55 默*为 阅读(64) 评论(0) 推荐(0) 编辑