随笔分类 -  C++ 学习之旅

摘要:Virtual 作用: 允许在派生类中重新定义与基类同名函数并且可以通过其类的指针或引用来访问基类何派生类的同名函数。 1. 概述简单地说,每一个含有虚函数(无论是其本身的,还是继承而来的)的类都至少有一个与之对应的虚函数表,其中存放着该类所有的虚函数对应的函数指针。例: 其中:• B的虚函数表中存 阅读全文
posted @ 2017-11-09 10:42 潘探 阅读(1038) 评论(0) 推荐(0)
摘要:#include "iostream"#include "queue"using namespace std;void main12(){ queue q; for (int i = 0; i &q){ while (!q.empty()) { Teacher* temp = q.front()... 阅读全文
posted @ 2015-08-25 23:49 潘探 阅读(163) 评论(0) 推荐(0)
摘要:#include "iostream"#include "stack"using namespace std;void main12(){ stack s; //定义一个栈 for (int i = 0; i &s){ while (!s.empty()) { cout s; s.push... 阅读全文
posted @ 2015-08-25 22:56 潘探 阅读(202) 评论(0) 推荐(0)
摘要:#include "iostream"#if 0 //不同类型的参数 作交换函数 void swap(int &a,int &b) { int c ; c = a; a = b; b = c; } void swap2(float &a, float &b) { flo... 阅读全文
posted @ 2015-08-19 23:05 潘探 阅读(556) 评论(0) 推荐(0)
摘要:函数的指针#include "stdio.h"#include "stdlib.h"#include "string.h"#if 0 //定义一个函数类型 typedef int Func(int);//函数名称就代表函数的入口地址 函数名称本身就是一个指针int test(int a){ ... 阅读全文
posted @ 2015-08-19 00:16 潘探
摘要:学习C++ -> 构造函数与析构函数一、构造函数的介绍 1. 构造函数的作用 构造函数主要用来在创建对象时完成对对象属性的一些初始化等操作, 当创建对象时, 对象会自动调用它的构造函数。一般来说, 构造函数有以下三个方面的作用: ■ 给创建的对象建立一个标识符; ■ 为对象数据成员开辟内存... 阅读全文
posted @ 2015-06-26 11:30 潘探 阅读(199) 评论(0) 推荐(0)
摘要:VS2013常用快捷键:1.回到上一个光标位置/前进到下一个光标位置1)回到上一个光标位置:使用组合键“Ctrl + -”;2)前进到下一个光标位置:“Ctrl + Shift + - ”。2.复制/剪切/删除整行代码1)如果你想复制一整行代码,只需将光标移至该行,再使用组合键“Ctrl+C”来完成... 阅读全文
posted @ 2015-06-25 19:22 潘探 阅读(169) 评论(0) 推荐(0)
摘要:#includeusing namespace std;template T max(T a, T b){ return a > b ? a : b;}int main(int argc,char* argv[]){ int x = 10; int y = 20; cout > x; return ... 阅读全文
posted @ 2015-06-25 17:51 潘探 阅读(815) 评论(0) 推荐(0)
摘要:#include#include#includeusing namespace std;class A{public: A(int x, int y) :m_x(x), m_y(y) { } int compare(void) { cout m_y) return 1; return ... 阅读全文
posted @ 2015-06-25 16:31 潘探 阅读(150) 评论(0) 推荐(0)