![](https://img-blog.csdnimg.cn/20201014180756928.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
C++
文章平均质量分 65
D8
这个作者很懒,什么都没留下…
展开
-
C++ 面试题
一、用变量 a 给出下面的定义:一个整型数。 Int a 一个指向整型数的指针。Int *a;一个指向指针的的指针,它指向的指针是指向一个整型数。Int **a;一个有 10 个整型数的数组。Int a[10];一个有 10 个指针的数组,该指针是指向一个整型数的。Int *a[10];一个指向有 10 个整型数数组的指针。Int **a[10];一个指向函数的指针,原创 2013-07-15 13:04:24 · 431 阅读 · 0 评论 -
boost socket编程 例子
服务端程序代码: 1 // BoostServer.cpp : 定义控制台应用程序的入口点。 2 // 3 4 #include "stdafx.h" 5 #include 6 #include 7 8 using namespace boost::asio; 9 #define BLOCK_SIZE 64*102410 11转载 2013-07-23 10:37:59 · 685 阅读 · 0 评论 -
C mysql
#include #include #include #include // 进行网络编程需要winsock2.h#include #include #include #pragma comment(lib, "libmysql.lib")#pragma comment(lib ,"ws2_32")using namespace std;MYSQL mys原创 2013-08-07 10:55:08 · 439 阅读 · 0 评论 -
C++ 成员函数指针
#include using namespace std;class P{public:P(int _m):m(_m){}virtual void print(){printf("P:%d\n",m);}int m; };class PP:public P{public: PP(int _m):P(_m) {原创 2013-08-30 22:25:30 · 381 阅读 · 0 评论 -
C++偏特化
#include using namespace std;templateclass Function{public:typedef TT (*PFUN)(P param,P2 param2);Function(PFUN fun):m_fun(fun),m_p(0),m_p2(0){}Function(PFUN fun,P p1,P2 p2):m_fun(f原创 2013-09-01 17:25:53 · 499 阅读 · 1 评论 -
C++ 简单的观察者模式
#include using namespace std;#define MAX_NUM 5class CObserve{public:CObserve(){}virtual void DoSomeThing()=0;/*templatevoid RegisterFunction(){}*/};class CObserveObje原创 2013-09-03 17:07:11 · 515 阅读 · 0 评论 -
基本的模板元编程
#include template struct fl{enum { value = N * fl::value };};template struct fl{enum{value = 1};};int main(int argc, char *argv[]){printf("%d\n",fl::value);getc原创 2013-09-11 19:53:51 · 496 阅读 · 0 评论 -
堆排序
#include #include #include templatevoid Sort(A * array, int max_node,bool re){if(re){SortBig2Small(array , max_node);}else{SortSmall2Big(array , max_node);}}templ原创 2013-10-09 13:57:01 · 391 阅读 · 0 评论 -
控制台版贪吃蛇
#include#include#include#include#include//地图大小#define MAP_SIZE 20//全局屏幕输出缓存区句柄HANDLE g_hOutput;//地图属性struct MapNode_s{enum NodeType_e{NOTHING, SNAKE , WALL, FOOD};NodeType_e原创 2013-10-13 02:07:15 · 496 阅读 · 0 评论 -
简单的事件机制
#include#include#define ObjDef(class_name) \s_ClassName = #class_name; \v_id = this;class CObject;class CEvent;class CSendEvent;class CEventsManage;class CObject{public:原创 2014-11-16 00:19:16 · 376 阅读 · 0 评论 -
二分查找算法
二分查找算法 二分查找算法是在有序数组中用到的较为频繁的一种算法,在未接触二分查找算法时,最通用的一种做法是,对数组进行遍历,跟每个元素进行比较,其时间为O(n).但二分查找算法则更优,因为其查找时间为O(lgn),譬如数组{1, 2, 3, 4, 5, 6, 7, 8, 9},查找元素6,用二分查找的算法执行的话,其顺序为: 1.第一步查找中间元素,即5,由于5转载 2013-07-20 18:59:11 · 486 阅读 · 0 评论 -
二叉树查找树...
#include #include #include #include using namespace std;//R 大 L 小 struct Node{Node* L;Node* R;Node* root;int data;Node(int d=0):data(d),L(),R(){}};class bst{ int n;public原创 2013-07-20 17:24:25 · 364 阅读 · 0 评论 -
C++ map的基本操作和使用
Map是c++的一个标准容器,她提供了很好一对一的关系,在一些程序中建立一个map可以起到事半功倍的效果,总结了一些map基本简单实用的操作!1. map最基本的构造函数; mapmapstring; mapmapint; mapmapstring; mapmapchar; mapmapchar; mapmapint转载 2013-07-15 14:09:39 · 404 阅读 · 0 评论 -
函数指针
#include using namespace std;typedef int (*px)(int , int);int p(int a,int b){coutreturn 0; }int a(int(*ax)(int), int x){return ax(x);}int b(int x){return x;}/*i原创 2013-07-15 19:35:25 · 327 阅读 · 0 评论 -
读文件
#include #include #include using namespace std;vector * retrieve_text(){string file_name;file_name="mc.txt";ifstream infile(file_name.c_str(),ios::in);vector *text = new vector;str原创 2013-07-15 19:37:11 · 330 阅读 · 0 评论 -
C++ 强制类型转换
关于强制类型转换的问题,很多书都讨论过,写的最详细的是C++ 之父的《C++ 的设计和演化》。最好的解决方法就是不要使用C风格的强制类型转换,而是使用标准C++的类型转换符:static_cast, dynamic_cast。标准C++中有四个类型转换符:static_cast、dynamic_cast、reinterpret_cast、和const_cast。下面对它们一一进行介绍。转载 2013-07-17 09:39:33 · 360 阅读 · 0 评论 -
二叉查找树(二叉排序树)的详细实现
1、序 详细实现了二叉查找树的各种操作:插入结点、构造二叉树、删除结点、查找、 查找最大值、查找最小值、查找指定结点的前驱和后继2、二叉查找树简介 它或者是一棵空树;或者是具有下列性质的二叉树: (1)若左子树不空,则左子树上所有结点的值均小于它的根结点的值; (2)若右子树不空,则右子树上所有结点的值均大于它的根结点的值; (3)左、右子树也分别为二叉排序树转载 2013-07-16 19:33:59 · 404 阅读 · 0 评论 -
二叉树的非递归遍历
二叉树是一种非常重要的数据结构,很多其它数据结构都是基于二叉树的基础演变而来的。对于二叉树,有前序、中序以及后序三种遍历方法。因为树的定义本身就是递归定义,因此采用递归的方法去实现树的三种遍历不仅容易理解而且代码很简洁。而对于树的遍历若采用非递归的方法,就要采用栈去模拟实现。在三种遍历中,前序和中序遍历的非递归算法都很容易实现,非递归后序遍历实现起来相对来说要难一点。一.前序遍历转载 2013-07-17 13:24:51 · 327 阅读 · 0 评论 -
time.h库简单应用
#include #include //CLOCKS_PER_SEC ((clock_t)1000) 表示一秒钟会有多少个时钟计时单元int main(int argc, char *argv[]){clock_t n,m;printf("%ld\n",CLOCKS_PER_SEC); n=clock(); // clock() 程序已经运行过的时间 毫秒为单位 返原创 2013-07-17 14:13:11 · 652 阅读 · 0 评论 -
C++ mutable
mutalbe的中文意思是“可变的,易变的”,跟constant(既C++中的const)是反义词。 在C++中,mutable也是为了突破const的限制而设置的。被mutable修饰的变量,将永远处于可变的状态,即使在一个const函数中。 我们知道,如果类的成员函数不会改变对象的状态,那么这个成员函数一般会声明成const的。但是,有些时候,我们需要在const的函数里面转载 2013-07-19 09:45:27 · 350 阅读 · 0 评论 -
二分排序
#include void f(int *a,int len){if(lenreturn ;int i;int t=0,w=len-1;int c[len];for(i=1;i{if(a[i]>a[0]){c[w]=a[i];w--;}else{c[t]=a[i];t++; } }c[w]=a[0];for(i原创 2013-07-20 17:24:43 · 386 阅读 · 0 评论 -
vs2012 正则
#pragma warning(disable : 4996)// std_tr1__regex__regex_replace.cpp // compile with: /EHsc #include #include #include #include#define FIND_CHAR "a"#define REPLACE_CHAR "A"#define F原创 2015-06-15 12:51:06 · 352 阅读 · 0 评论