- 博客(6)
- 资源 (1)
- 收藏
- 关注
原创 引用
一、什么是引用 引用不是定义一个新的变量,而是给某一已有的变量起一个别名,对引用的操作与对变量直接操作完全一样。 引用的格式: 类型 &引用变量名=目标变量名; 【例1】:int a; int &ra=a; //定义引用ra,它是变量a的引用,即别名 说明: (1)&在此不是求地址运算,而是起标识作用。 (...
2018-05-21 18:42:06 764
原创 Linux下实现进度条和彩色进度条
一、普通进度条#include #include int main() { char buf[101] = {}; int i =0; char *ptr = "|/-\\"; for(i = 0; i < 100 ; i++) { buf[i] = '#'; printf
2018-05-07 17:57:06 354
原创 C++多态之带有虚函数的菱形继承与菱形虚拟继承
一、菱形继承那就先从菱形继承开始复习如下代码:#include<iostream> using namespace std;class A{public: int _a;};class B : public A{public: int _b;};class C : public A{public: int _c;};class D : pub...
2018-05-06 19:19:48 695
原创 C++多态的实现原理
一、多态的概念 多态就是多种形态,C++的多态分为静态多态与动态多态。静态多态就是重载,因为在编译期决议确定,所以称为静态多态。在编译时就可以确定函数地址。动态多态就是通过继承重写基类的虚函数实现的多态,因为实在运行时决议确定,所以称为动态多态。运行时在虚函数表中寻找调用函数的地址。 在基类的函数前加上virtual关键字,在派生类中重写该函数,运行时将会根据对象的实...
2018-05-05 13:22:47 31781 7
原创 C++继承之菱形继承与虚函数
一、单继承&多继承&菱形继承单继承与多继承 单继承:一个子类只有一个直接父类时称这个继承关系为单继承 多继承:一个子类有两个或以上直接父类时称这个继承关系为多继承菱形继承菱形继承引发的问题:数据冗余例:B、C中的_a都是来自于A,其实两个_a是同一个,但是因为B、C各自继承,产生了两份,造成了数据冗余二义性例:由于D继承于B、C,B、C继承于A,所以D中的_a不知道是来自B还是来自...
2018-05-03 12:26:50 1035
原创 C++继承之继承基础
一、继承的相关概念 继承是⼀种复⽤⼿段,在继承关系⾥子类继承父类的成员,由此达到复⽤的⽬的。通过继承定义一个类,继承是类型之间的关系建模,共享公有的东西,实现各自本质不同的东西。二、三种访问限定符&继承关系三、继承的重要说明1.子类拥有父类的所有成员变量和成员函数2.子类就是一种特殊的父类3.子类对象可以当作父类对象使用4.子类可以拥有父类没有的方法和属性四.派生类(子类)的访问控制...
2018-05-02 22:32:39 269
UNIX环境高级编程
2017-11-18
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人