摘要: 1.非常量成员函数返回非常量 *this,常量成员函数返回常量 *this,指向常量对象。 2.重载函数必须参数数量或者类型不同吗? 答案是:否。还存在一种const重载; Person.h #pragma once #include <iostream> #include <string> #in 阅读全文
posted @ 2020-02-10 20:26 强威 阅读(283) 评论(0) 推荐(0) 编辑
摘要: 1.修饰变量 const int i = 0; // i 为常量,不可修改 const int* p = &i; // 指向常量的指针 int* const p = &i; // 指针为常量,指向i不可修改 const int &r = i; // 常量引用,不可通过r修改i typedef int 阅读全文
posted @ 2020-02-10 17:56 强威 阅读(154) 评论(0) 推荐(0) 编辑