c++数据结构与算法
Luke2022_
这个作者很懒,什么都没留下…
展开
-
c++类实例化的两种方式
/* * HelloWorld.cpp * * Created on: 2016年7月13日 * Author: zroad */#include<iostream>#include<cstring>#include<string>using namespace std;class C {public: C(string s = "", int i = 0, d原创 2016-07-16 22:57:40 · 20383 阅读 · 1 评论 -
const关键字
/* * constDecorate.cpp * * Created on: 2016年8月31日 * Author: zroad */#include<iostream>using namespace std;//三、const修饰类的成员方法://1、该成员函数无法修改成员变量//2、该成员函数无法调用非const成员函数class ConstIns{public转载 2016-09-05 00:00:26 · 308 阅读 · 0 评论 -
虚函数及纯虚函数
/* * virtualVar.cpp * * Created on: 2016年8月24日 * Author: zroad */#include<iostream>using namespace std;//一。虚函数的概念:/* * 1、虚函数的定义:类Base中加了Virtual关键字的函数就是虚拟函数(例如函数print), * 2、多态的实现:于是在Base原创 2016-08-25 00:02:47 · 265 阅读 · 0 评论 -
函数指针
/* * functionPoint.cpp * * Created on: 2016年8月22日 * Author: zroad */#include<iostream>using namespace std;//函数指针的概念:/* * 函数指针: * 1.函数的一个属性就是其地址指明了函数体在内存中的位置。 * 2、C在编译时,每一个函数都有一个入口地址,该入口原创 2016-08-22 23:25:36 · 292 阅读 · 0 评论 -
空指针与野指针
/* * zeroPoint.cpp * * Created on: 2016年8月29日 * Author: zroad */#include<iostream>#include<string>#include<cstring>#include<stdlib.h>using namespace std;class A {public: void Func(v原创 2016-08-29 23:16:06 · 549 阅读 · 0 评论 -
指针与引用变量
#include<iostream>#include<string>using namespace std;int main() { int n = 5, *p = &n, &r = n; cout << n << " " << *p << " " << r << endl; n = 7; cout << n << " " << *p << " " << r <<原创 2016-08-18 23:27:49 · 245 阅读 · 0 评论 -
析构函数
/* * deleteFunc.cpp * * Created on: 2016年8月17日 * Author: zroad */#include<string>#include<iostream>using namespace std;bool being = true;class Fruit {public: void print() { cou原创 2016-08-17 22:58:22 · 254 阅读 · 0 评论 -
struct基础
/* * structBase.cpp * * Created on: 2016年8月1日 * Author: zroad */#include<iostream>#include<cstring>using namespace std;int main() { //一、声明结构体: //结构体:由一系列具有相同类型或不同类型的数据构成的数据集合,也叫结构原创 2016-08-02 00:22:51 · 324 阅读 · 0 评论 -
指针与数组
/* * pointArray.cpp * * Created on: 2016年7月21日 * Author: zroad */#include<iostream>#include<string>using namespace std;//数组初始化1string b[4] = {"a", "b", "c", "d"};//数组初始化2/* * 未初始化数据规则:原创 2016-07-21 22:27:27 · 258 阅读 · 0 评论 -
指针变量
/* * pointDemo.cpp * * Created on: 2016年7月20日 * Author: zroad */#include<iostream>using namespace std;void pointVar() { //变量j若未初始化,系统将随即给该变量赋值 int i = 15, j, *p, *q; cout << "i=原创 2016-07-20 23:15:55 · 278 阅读 · 0 评论 -
类继承、虚继承
/* * inheritClass.cpp * * Created on: 2016年7月18日 * Author: zroad */#include<iostream>#include<cstring>using namespace std;class BaseClass {public: BaseClass() {} void f(char *s = "原创 2016-07-18 22:09:38 · 315 阅读 · 0 评论 -
函数对象
/* * funcObject.cpp * * Created on: 2016年8月26日 * Author: zroad */#include<iostream>#include<string>using namespace std;//一、函数对象的概念//函数对象:即一个重载了括号操作符"()"的对象。当用该对象调用此操作符时,//其表现形式如同普通函数调用一般,原创 2016-08-26 22:24:47 · 412 阅读 · 0 评论