摘要:
在类中我们可以让另一个类作为本类的成员 注意本节课学习在头文件和源文件中的声明(105节) 点击查看代码 #include<iostream> #include<string> using namespace std; //点和圆的关系案例 //点类 class Point { public: // 阅读全文
posted @ 2021-07-19 19:12
毋纵年华
阅读(27)
评论(0)
推荐(0)
摘要:
判断两个立方体是否相等 #include<iostream> #include<string> using namespace std; //立方体类设计 //1、创建立方体类 //2、设计属性 //3、设计行为获取立方体面积和体积 //4、分别利用全局函数和成员函数判断两个立方体是否相等 clas 阅读全文
posted @ 2021-07-19 16:57
毋纵年华
阅读(38)
评论(0)
推荐(0)
摘要:
成员属性私有化设置 点击查看代码 #include<iostream> #include<string> using namespace std; //成员属性设置为私有 //1、可以自己控制读写权限 (提供接口) //2、对于写可以检测数据的有效性 class Person { public: / 阅读全文
posted @ 2021-07-19 16:02
毋纵年华
阅读(59)
评论(0)
推荐(0)
摘要:
class和struct的区别 点击查看代码 #include<iostream> #include<string> using namespace std; //struct和class区别 //struct 默认权限是 公共public //class 默认权限是 私有private class 阅读全文
posted @ 2021-07-19 15:05
毋纵年华
阅读(51)
评论(0)
推荐(0)
摘要:
封装意义 点击查看代码 #include<iostream> #include<string> using namespace std; //访问权限 //三种 //公共权限(public) 成员类内可以访问 类外可以访问 //保护权限(protected) 成员类内可以访问 类外不可以访问(继承性 阅读全文
posted @ 2021-07-19 14:46
毋纵年华
阅读(39)
评论(0)
推荐(0)
摘要:
类和对象 、封装 点击查看代码 #include<iostream> using namespace std; const double PI = 3.14; //class 代表设计一个类,类后面紧跟类的名称 class Circle { //1_访问权限 public: //2_属性 int m 阅读全文
posted @ 2021-07-19 13:47
毋纵年华
阅读(175)
评论(0)
推荐(0)