摘要: 指向类成员(成员变量和成员方法)的指针 1:定义一个指针指向类的普通成员变量 示例代码1 class Test2{ public: int ma; static int mb; void f1(){cout<<"Test::void f1()"<<endl;} static void static_ 阅读全文
posted @ 2022-11-13 21:54 Hello_Bugs 阅读(101) 评论(0) 推荐(0) 编辑
摘要: 类的各种成员-> 成员方法 & 成员变量 普通的成员方法=>编译器会添加一个this形参变量 1:属于类的作用域 2:调用该方法时,需要依赖一个对象,而且常对象不能调 3:可以任意的访问对象的私有成员变量 const 常成员方法 => const student *this 1:属于类的作用域 2: 阅读全文
posted @ 2022-11-13 17:49 Hello_Bugs 阅读(68) 评论(0) 推荐(0) 编辑
摘要: 示例代码1 class CDate{ public: CDate(int _year,int _month, int _day){ this->year=_year; this->month=_month; this->day=_day; } private: int year; int month 阅读全文
posted @ 2022-11-13 16:30 Hello_Bugs 阅读(175) 评论(0) 推荐(0) 编辑
摘要: 先看示例代码 #include <iostream> #include<cstring> using namespace std; class Student{ public: Student(int _age , const char * _name) { this->age=_age; int 阅读全文
posted @ 2022-11-13 11:16 Hello_Bugs 阅读(63) 评论(0) 推荐(0) 编辑