【C++】如果你准备学习C++,并且有C语言的基础,我希望你能简单的过一遍知识点。 | 您所在的位置:网站首页 › 中文怎么学零基础的语言 › 【C++】如果你准备学习C++,并且有C语言的基础,我希望你能简单的过一遍知识点。 |
相关视频——黑马程序员匠心之作|C++教程从0到1入门编程,学习编程不再难_哔哩哔哩_bilibili(1-83) 我的小站——半生瓜のblog 我知道这个视频早已经被很多人学习并且记录笔记,但是我还是想再过一遍前面的基础知识点,所以我这个笔记会非常的简洁,适合有C语言基础的小伙伴进行简单的基础知识复习,好尽快投入到C++的学习中。 在基础知识部分,好像只有头文件的引用和输入输出函数发生了变化。 头文件下加入using namespace std; #include——>#include< iostream> printf——>cout scanf——>cin C++有字符串类型string,这是C语言所不具备的。 下面就让我们开始吧! 作用:通过指针访问结构体中的成员 利用操作符->可以通过结构体指针访问结构体属性 struct Student s1; struct Student* p = &s1; p->score = 10; 结构体嵌套结构体作用:结构体中的成员可以是另一个结构体 例如:每个老师辅导一个学员,一个老师的结构体中,记录一个学生的的结构体 结构体做函数参数作用:将结构体作为参数向函数中传递 传递方式有两种 同上函数参数-指针 值传递-无法改变实参地址传递-可以改变实参 结构体中const使用场景作用:用const来防止误操作 void ChangeInformation(const struct student* stu1) { 加了const就无法改变该结构体内的信息 } 结构体案例每个老师带三个学生 #include #include #include using namespace std; struct Student { string name; int age; int score; }; struct Teacher { string name; struct Student sArry[5]; }; void inPutInformation(struct Teacher tArry[], int len) { string Name = "ABCDE"; for (int i = 0; i < len; i++) { tArry[i].name = "Teacher_"; tArry[i].name += Name[i]; for (int j = 0; j < 5; j++) { tArry[i].sArry[j].name = "Student_"; tArry[i].sArry[j].name += Name[j]; int random = rand()% 60 +40; tArry[i].sArry[j].score = random; } } } void printInformation(struct Teacher tArry[],int len) { for (int i = 0; i < len; i++) { cout |
CopyRight 2018-2019 实验室设备网 版权所有 |