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)

导航