摘要: #include#include#includeusing namespace std;/* 4.2 对象的初始化和清理 4.2.4 构造函数调用规则 默认情况下创建一个类,C++编译器至少给该类添加3个函数: ... 阅读全文
posted @ 2021-03-15 17:31 yub4by 阅读(29) 评论(0) 推荐(0)
摘要: #include#include#includeusing namespace std;/* 4.2 对象的初始化和清理 4.2.3 拷贝构造函数调用时机 三种情况下会调用: 使用一个已创建完毕的对象来初始化一个新对象 ... 阅读全文
posted @ 2021-03-15 17:30 yub4by 阅读(47) 评论(0) 推荐(0)
摘要: #include#include#includeusing namespace std;/* 4.2 对象的初始化和清理 4.2.2 构造函数的分类及调用 按参数分:有参构造、无参构造(默认构造) 按类型分:普通构造、拷... 阅读全文
posted @ 2021-03-14 20:57 yub4by 阅读(22) 评论(0) 推荐(0)
摘要: #include#include#includeusing namespace std;/* 4.2 对象的初始化和清理 4.2.1构造函数和析构函数 构造函数-初始化 类名(){} 可以有参数,可重载;没有返回值,不... 阅读全文
posted @ 2021-03-14 20:56 yub4by 阅读(28) 评论(0) 推荐(0)
摘要: point.h /*#ifndef POINT_H_INCLUDED#define POINT_H_INCLUDED#endif // POINT_H_INCLUDED*/#pragma once#includeusing namespace std;clas... 阅读全文
posted @ 2021-03-14 18:39 yub4by 阅读(25) 评论(0) 推荐(0)
摘要: #include#includeusing namespace std;/* 4.1 封装 案例*2*/// -----------------------------------------------------------------... 阅读全文
posted @ 2021-03-14 18:31 yub4by 阅读(32) 评论(0) 推荐(0)
摘要: #include#includeusing namespace std;/* 4.1 封装 成员属性设置为私有的优点: 可以自己控制读写权限 对于写权限,可以检测数据有效性*/class Pers... 阅读全文
posted @ 2021-03-14 18:30 yub4by 阅读(45) 评论(0) 推荐(0)
摘要: #includeusing namespace std;/* 4.1 封装 访问权限: 公共 public 其中的成员在类内+类外均可访问 保护 protected ... 阅读全文
posted @ 2021-03-14 18:29 yub4by 阅读(47) 评论(0) 推荐(0)
摘要: #include#includeusing namespace std;#define PI 3.14/* 4.1 封装 C++面向对象三大特性:封装、继承、多态 封装意义: 设计类时可以将属性和行为作为... 阅读全文
posted @ 2021-03-14 18:27 yub4by 阅读(62) 评论(0) 推荐(0)
摘要: #includeusing namespace std;/* 三 函数提高 3.3 函数重载 函数名可以相同以提高复用性 函数重载需满足的条件: 同意作用域下 函数名相同 ... 阅读全文
posted @ 2021-03-14 15:20 yub4by 阅读(27) 评论(0) 推荐(0)