2021年1月6日

类的构造函数

摘要: 6、小作业:有这么个需求,所有的在校生都必须有学号,所以能不能实现实例化一个Student对象之后,就要求输入学号,不存在一个没有学号的Student对象被实例化出来,大家明白了吗?也就是类似于 stud1 这样的对象是不允许存在的,因为其没有学号。大家课后试着做一下! #pragma once # 阅读全文

posted @ 2021-01-06 20:31 SakuraQAQ 阅读(69) 评论(0) 推荐(0)

this指针

摘要: 4、什么情况下需要手动加上this: class Student { public: char name[50]; int num; int age; public: void set_age(int age) { age = age; }; }; 大家看到了吗?set_age 函数的参数名字和成员 阅读全文

posted @ 2021-01-06 16:42 SakuraQAQ 阅读(32) 评论(0) 推荐(0)

2021年1月5日

类的成员函数

摘要: 5、小作业: 类的声明和实现大家自己课后用VS2013练习如何添加类吧 #pragma once #include <iostream> #include <string> using namespace std; class CStudent { string name; int age; pub 阅读全文

posted @ 2021-01-05 22:41 SakuraQAQ 阅读(73) 评论(0) 推荐(0)

类的声明

摘要: 6、小作业:自己定义一个学生类,将该类的所有成员变量都声明为私有的,并添加一个共有的成员函数,实现从键盘录入该类对象的学生信息。 #include <iostream> #include <string> using namespace std; class CStudent { string s_ 阅读全文

posted @ 2021-01-05 21:27 SakuraQAQ 阅读(100) 评论(0) 推荐(0)

引用及new和delete的使用

摘要: 8、小作业:完成 get_same_string 函数的功能! #include <iostream> using namespace std; char* get_same_string(char* x,char* y) { int str1 = strlen(x); int str2 = str 阅读全文

posted @ 2021-01-05 15:41 SakuraQAQ 阅读(83) 评论(0) 推荐(0)

2021年1月3日

枚举类型及定义新的类型名字

摘要: 5、小作业:课后自己练习定义枚举类型变量以及使用 typedef 定义新的类型名! #include <iostream> using namespace std; enum Week { Day1, Day2, Day3, Day4, Day5, Day6, Day7 }; typedef uns 阅读全文

posted @ 2021-01-03 21:53 SakuraQAQ 阅读(268) 评论(0) 推荐(0)

结构体数组与指针

摘要: 5、小作业:①、根据运算符的优先级,大家想一下:Student stu[2] ={ { "aaa", 0, 'f', 10 }, { "bbb", 0, 'm', 12 }};Student* pstu = stu;++p->num = 202; //这句代码执行之后,到底是stu[0] 的 num 阅读全文

posted @ 2021-01-03 20:26 SakuraQAQ 阅读(293) 评论(0) 推荐(0)

统计共有多少个整数,并输出这些整数。

摘要: 5、小作业:输入一个字符串,例如:a123x456__17960?302ab5876将其中连续的数字作为一个整数,依次存放到一个数组中a中,例如:123放在a[0]中,456放在a[1]中。统计共有多少个整数,并输出这些整数。 #include <iostream> using namespace 阅读全文

posted @ 2021-01-03 16:46 SakuraQAQ 阅读(150) 评论(0) 推荐(0)

导航