上一页 1 ··· 3 4 5 6 7 8 9 10 11 ··· 38 下一页
摘要: 引用的本质 一个常量指针 #include<iostream> using namespace std; void crzaychange(int &a, int &b) { int c; c = a; a = b; b = c; } void main() { int a = 100; int b 阅读全文
posted @ 2019-12-18 00:13 saintdingtheGreat 阅读(136) 评论(0) 推荐(0) 编辑
摘要: 重要意义:间接赋值的意义,实现了模块的功能划分,实现了软件作品的分层,使得模块接口和信息系统得以实现。 所谓二级指针就是指向指针的指针,其声明形式如下 int *p=NULL int **p1=NULL; p1=&p; 一级指针*运算,从所指向内存空间取出数值(类比:一级指针是藏宝图,所指向的内存空 阅读全文
posted @ 2019-12-17 13:26 saintdingtheGreat 阅读(1337) 评论(0) 推荐(0) 编辑
摘要: char *其实就是char[length]的首元素地址 实验环境:centos7下qt5.11 中文char类型占3个字节 char[length]="特别车队"其实等价于char *mywords="特别车队" #include<stdio.h> #include<stdlib.h> #incl 阅读全文
posted @ 2019-12-16 12:54 saintdingtheGreat 阅读(204) 评论(0) 推荐(0) 编辑
摘要: 函数模板存在的意义;如果同一函数,参数类型有所不同,相同的功能可能会定义多个函数实例,这十分繁冗 #include<iostream> using namespace std; void swap(int &a,int &b) { int temp = a; a = b; b = temp; } v 阅读全文
posted @ 2019-12-15 17:11 saintdingtheGreat 阅读(187) 评论(0) 推荐(0) 编辑
摘要: 函数定义期望 通过cout<<对象,打印出复数的实部和虚部,这样一来,就需要重载cout类的位移<<运算函数,但是我们并不能拿到cout源码,在visual studio我们看到的也仅仅是他的定义 若想访问c1的私有属性,则应当声明为友元函数 通过定义可以看出cout类的返回值是ostream类型的 阅读全文
posted @ 2019-12-15 15:56 saintdingtheGreat 阅读(2270) 评论(0) 推荐(0) 编辑
摘要: 运算符重载是为了解决这样一类问题:我们知道对于整型可以用二元运算符(就是+,-,*,/因为这些运算都是两个变量参与,所以谓之二元,相比之下一元运算符就是自增,自减运算)直接进行运算,但对于类这样的数据结构直接的加减运算显然不被支持,这就需要用到运算符重载的概念 全局函数形式 返回类型 operato 阅读全文
posted @ 2019-12-15 14:55 saintdingtheGreat 阅读(404) 评论(0) 推荐(0) 编辑
摘要: 打造c++抽象类 与其他语言的抽象类相似,抽象类不能实例化,也不能作为函数的参数,只可以作为指针类型或者引用类型 抽象类的基本特征 #pragma once #include<iostream> using namespace std; class jetplane { private: prote 阅读全文
posted @ 2019-12-13 07:55 saintdingtheGreat 阅读(225) 评论(0) 推荐(0) 编辑
摘要: 首先我们随意定义4个类结构 class cl1 { private: int age; string name; static int addr; public: cl1() { } void iwasthelastlivingsoul() { } int getage() { return thi 阅读全文
posted @ 2019-12-12 22:10 saintdingtheGreat 阅读(312) 评论(0) 推荐(0) 编辑
摘要: 多年前就粉c++,认为这是黑客专门用的语言,到现在这种情怀仍有增无减;那时朦朦胧胧的看到友元函数这个词顿时觉得深不可测;其实通过下面的例子我们不难发现,友元函数就是在类方法之外,通过函数访问类的私有成员的一种方法声明。不像人话是么?先看这样一个例子 定义了一个坐标点的类用于计算两点间的距离(参见解析 阅读全文
posted @ 2019-12-11 02:16 saintdingtheGreat 阅读(433) 评论(0) 推荐(0) 编辑
摘要: 简单定义并间接调用 #define _CRT_SECURE_NO_WARNINGS #include<stdio.h> #include<time.h> void singasong() { printf("%s\n","我爱的你啊,我爱的你,你在哪里啊,在哪里~"); } void main() 阅读全文
posted @ 2019-12-10 21:37 saintdingtheGreat 阅读(200) 评论(0) 推荐(0) 编辑
上一页 1 ··· 3 4 5 6 7 8 9 10 11 ··· 38 下一页