![](https://img-blog.csdnimg.cn/20201014180756757.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
程序人生
人间正道是沧桑80
天若有情天亦老,人间正道是沧桑
展开
-
多态案例-制作饮品
使用多态来制作咖啡和茶。原创 2022-07-24 23:07:15 · 177 阅读 · 0 评论 -
递增运算符重载
#if 1#includeusing namespace std;class MyInteger{ friend ostream& operator原创 2022-07-11 21:53:56 · 242 阅读 · 0 评论 -
左移运算符重载
#if 0#includeusing namespace std;//左移运算符重载class Person{ friend ostream& operator原创 2022-07-11 21:27:54 · 250 阅读 · 0 评论 -
C++之类做友元
#if 1#includeusing namespace std;class Building;class GoodGay{public: GoodGay(); void visit();//参观韩束 访问building中的属性 Building* building;};class Building{ //GoodGay类是本类的好朋友,可以访问本类的私有成员 friend class GoodGay;public: Buildin...原创 2022-07-07 20:54:19 · 95 阅读 · 0 评论 -
全局函数做友元
#if 0#includeusing namespace std;//建筑物类class Building{ //goodGay全局函数是Building喊朋友,可以访问Building中私有成员 friend void goodGay(Building* building);public: Building() { m_SittingRoom = "客厅"; m_BedRoom = "卧室"; } st...原创 2022-07-07 20:53:37 · 89 阅读 · 0 评论 -
const修饰成员函数
#if 1#includeusing namespace std;class Person{public: //this指针的本质 是指针常量 指针的指向不可以修改 //const Person *const this; //在成员函数后面加const,修饰的是this指向,让指针指向的值也不可以修改 void showPerson() const { this->m_B = 100; //this->m_A =...原创 2022-07-07 20:23:51 · 136 阅读 · 0 评论 -
Source Insight崩溃的解决方法
不妨在桌面快捷方式上面右键-属性-兼容性-选择以兼容性运行(可以选择以win8还是win7运行)这个程序试试。原创 2022-07-06 17:44:20 · 885 阅读 · 0 评论 -
深拷贝与浅拷贝
#if 1#include using namespace std;//深拷贝与浅拷贝class Person{public: Person() { cout原创 2022-07-05 22:39:26 · 132 阅读 · 1 评论 -
构造函数调用原则
#if 1 //vs一个工程下面多个源文件编译,修改1为0可不进行编译#include using namespace std;//1、构造函数的调用规则//默认构造 空实现//析构函数 空实现//拷贝构造 值拷贝//2、// 如果我们写了有参构造函数,编译器就不再提供默认构造,依然提供拷贝构造// 如果我们写了拷贝构造函数,编译器就不再提供其他普通构造函数class Person{public: /*Person() { cou...原创 2022-07-05 22:12:19 · 123 阅读 · 0 评论 -
构造函数和析构函数
#include using namespace std;//对象的初始化和清理//1、构造函数 进行初始化操作class Person{ /* 1.1、构造函数 没有返回值 不用写void 函数名 与类名相同 构造函数可以有参数,可以发生重载 创建对象的时候,构造函数会自动调用,而且只调用一次 */public: Person() { cout ...原创 2022-07-04 23:26:29 · 102 阅读 · 0 评论 -
劳逸结合
劳逸结合才是最好的。辛苦coding一天,奖励自己放工一哈多么舒服。一直放松也会很空虚无聊。原创 2022-07-04 09:14:13 · 112 阅读 · 0 评论 -
C++返回局部变量地址
C++是不能返回局部变量地址的。int* func(){ int a = 10;//局部变量 存放在栈区,栈区的数据在执行完毕后自动释放。 return &a;}int main(){ int* p = func(); cout原创 2022-07-03 18:52:20 · 1332 阅读 · 3 评论 -
cin输入字母给整型变量问题
#include using namespace std;int main(){ int sex = 0; while(true) { int sex = 0; if(!(cin>>sex)) { cout sex; } else原创 2022-07-02 18:42:00 · 597 阅读 · 1 评论 -
努力,奋斗!!!
这个时代,总有一些人一些东西(不切实际的欲望和各种各样的诱惑都是这类东西),在你想努力往上攀爬的时候,把你拉下来,拉入泥潭,这个时候尤其要注意,要尽力反抗,不能被拉下去,因为一旦被拉下去,就很难再爬起来了。我们每天每时每刻都必须和这样的人和东西作斗争,因为思想一旦松懈,思想的土地一旦长满杂草,想除尽然后种满庄稼是需要很长时间的。努力,奋斗吧!加油小伙子,你可以的。...原创 2019-12-02 14:45:25 · 197 阅读 · 0 评论 -
C语言/C++中strcpy_s函数
C++标准中使用了更为安全的strcpy_s函数,strcpy_s包含在头文件<string.h>中,<cstring>也可,反正就改个名,其定义如下:_ACRTIMP errno_t __cdecl strcpy_s( _Out_writes_z_(_SizeInBytes) char* _Destination, ...原创 2019-11-18 14:38:41 · 7165 阅读 · 0 评论 -
C语言实现斐波那契数列
#include<stdio.h>int main(void){ int f1 = 0, f2 = 1,f3=0; for (int i = 0; i <= 10; i++) { f3 = f2 + f1; f1 = f2; f2 = f3; printf("%d ", f1); ...原创 2019-10-25 23:59:59 · 4975 阅读 · 0 评论