摘要: #includeusing namespace std;/* 二 引用 2.1&2.2 引用的语法和注意事项 作用:给变量取别名 语法:数据类型 &别名 = 原名 注意:引用必须初始化,且初始化后不可更改*... 阅读全文
posted @ 2021-03-12 15:54 yub4by 阅读(28) 评论(0) 推荐(0)
摘要: #includeusing namespace std;/* 1.3 new操作符 利用new在堆区创建数据时,会返回该数据对应的指针 new出来的堆区数据,手动释放用delete*/int * func(){ int * ... 阅读全文
posted @ 2021-03-12 13:09 yub4by 阅读(34) 评论(0) 推荐(0)
摘要: #includeusing namespace std;/* 1.2程序运行后 栈区 存放函数的参数、局部变量 注意:不要返回局部变量的地址,栈区开辟的数据由编译器自动释放 堆区 ... 阅读全文
posted @ 2021-03-12 13:08 yub4by 阅读(24) 评论(0) 推荐(0)
摘要: #includeusing namespace std;/* 一 内存分区模型 C++程序在执行时,将内存分为4个区域 1 代码区 存放函数体的二进制代码,由OS管理 2 全局区 ... 阅读全文
posted @ 2021-03-12 13:06 yub4by 阅读(56) 评论(0) 推荐(0)
摘要: #include#include#includeusing namespace std;#define MAX 1000struct Person{ string name; int sex; // 1男2女 int age; stri... 阅读全文
posted @ 2021-03-11 19:53 yub4by 阅读(33) 评论(0) 推荐(0)
摘要: #include#includeusing namespace std;/* 结构体-案例#2 三国英雄:5名英雄,通过冒泡排序按照年龄升序排列*/struct Hero{ string name; int age; string... 阅读全文
posted @ 2021-03-11 12:05 yub4by 阅读(40) 评论(0) 推荐(0)
摘要: #include#include#include //随机数用到#include //时间用到using namespace std;/* 结构体-案例#1 三个老师,每个老师带五个学生做毕设*/struct student{ strin... 阅读全文
posted @ 2021-03-11 12:05 yub4by 阅读(49) 评论(0) 推荐(0)
摘要: #include#includeusing namespace std;/* 结构体中const的使用场景 用const来防止误操作*/struct student{ string name; int age; int score... 阅读全文
posted @ 2021-03-11 12:05 yub4by 阅读(115) 评论(0) 推荐(0)
摘要: #include#includeusing namespace std;/* 结构体做函数参数 值传递&地址传递*/struct student{ string name; int age; int score;};voi... 阅读全文
posted @ 2021-03-11 12:05 yub4by 阅读(95) 评论(0) 推荐(0)
摘要: #include#includeusing namespace std;/* 结构体嵌套结构体*/struct student{ string name; int age; int score;};struct teacher{ ... 阅读全文
posted @ 2021-03-11 12:04 yub4by 阅读(69) 评论(0) 推荐(0)