C++
yyyllla
这个作者很懒,什么都没留下…
展开
-
黑马程序员匠心之作-4.4友元
4.4.1全局函数做友元#include <iostream>#include<string>#include<ctime>using namespace std;class Building{ friend void goodfriend(Building* b);public: string m_sittingroom; Building() { m_sittingroom = "客厅";...原创 2020-11-03 20:39:33 · 286 阅读 · 2 评论 -
黑马程序员匠心之作-4.3对象模型和this指针
4.3.1成员变量和成员函数分开存储1、成员变量与成员函数分开存储;2、只有非静态成员变量在类上3、当一个类中没有成员变量和成员函数时,仍然占一个字节的内存空间,目的是区分不同的空类4.3.2this指针概念#include<iostream>#include<string>using namespace std;//class Person {// int a;//非静态成员变量不属于类上// static int b;//静态成员变量属于...原创 2020-11-02 20:30:52 · 239 阅读 · 1 评论 -
黑马程序员匠心之作-4.2对象的初始化和清理
4.2对象的初始化和清理原创 2020-11-01 17:24:43 · 303 阅读 · 0 评论 -
黑马程序员匠心之作-封装实例
问题描述:核心1:在一个类中,可以让另一个类作为本类的成员。//要求://判断点与圆的关系#include<iostream>#include<string>using namespace std;class Circle{public: void setm_R(double R) { m_R = R; } double readm_R() { return m_R; } void setcenter(CenterPoi..原创 2020-10-28 22:20:40 · 920 阅读 · 0 评论 -
黑马程序员匠心之作-类和对象
c++面向对象三大特性:封装、继承、多态。c++认为世间万物都是对象,每个对象都有属性和行为。具有相同属性的对象抽象为类。4.1封装:4.1.1封装的意义1、将属性和行为作为一个整体;2、将属性和行为加以权限控制属性 ,行为#include<iostream>#include<string>using namespace std;class student{ //属性和行为统称为 成员 //属性:又称为 成员属性 成员变量 //...原创 2020-10-28 20:56:29 · 184 阅读 · 0 评论 -
黑马程序员匠心之作-引用
1、引用的含义与注意事项#include <iostream>using namespace std;#include<string>#include<ctime>int main(){ int a = 10;//a指向的内存值为10 int& b = a;//引用的定义,b与a指向同一个内存; cout << &a << "&b: " << &b <<原创 2020-10-28 11:37:34 · 259 阅读 · 2 评论 -
黑马程序员匠心之作-c++核心编程-内存分区模型
栈区:局部变量存放在栈区,栈区数据在函数执行完自动释放,因此不要返回局部变量的地址。堆区:原创 2020-10-28 10:37:24 · 143 阅读 · 0 评论 -
黑马程序员匠心之作笔记-指针
一,指针的定义指针的定义:P为一个指向a的指针。*P为P指向的单元的内容,即为a。二,指针类型的数据所占的空间大小查看指针类型数据所占的内存空间大小。在32位操作系统下均占4字节,在64为操作系统中均占8字节。三,空指针与野指针四,指针-const修饰指针4.1常量指针4.2指针常量4.3const既修饰指针又修饰常量五,指针和函数...原创 2020-10-26 21:09:00 · 122 阅读 · 0 评论 -
黑马程序员匠心之作=结构体
1,结构体定义2,结构体数组#include<iostream>#include<string>using namespace std;struct stu{ string name; int age; int score;};int main(){ stu stu1[2] = { {"张三",18, 90}, {"李四",18, 90} }; for (int i = 0; i < 2; i++) { cout &l原创 2020-10-27 10:28:53 · 151 阅读 · 2 评论 -
黑马程序员匠心之作-结构体案例
#include <iostream>using namespace std;#include<string>#include<ctime>struct student1{ string name; int score;};struct teature{ string name; student1 stu[5];};void allocate(teature tea[],int len){ string ...原创 2020-10-27 17:14:37 · 329 阅读 · 0 评论 -
黑马程序员匠心之作-通讯录
#include<iostream>#include<string>using namespace std;#define MAX 1000void showMenu(){ cout << "***********************" << endl; cout << "*****1、添加联系人*****" << endl; cout << "*****2、显示联系人*****" <&...原创 2020-10-27 21:45:17 · 414 阅读 · 0 评论