原创 C++版貪喫蛇

/*在VC2012中編譯通過,使用了c++11新特性,低版本的VC可能不能編譯*/ /*在dev-cpp中設置編譯器選項,使支持c++11,就可以編譯: 項目-->項目屬性-->編譯器-->代碼生成-->語言標準(-std),在下拉選項中

原创 五子棋人機對弈

#include "windows.h" #include <stdio.h> #include <stdlib.h> #include <conio.h> #ifndef __cplusplus #include <stdb

原创 基於MCI的音樂播放器

/*請使用VC2005以上版本編譯,VC6.0不能成功編譯*/#include <windows.h> #include <tchar.h> #include "Mmsystem.h" #include "Digitalv.h" #pra

原创 MCI實現播放器

</pre><pre name="code" class="cpp">VC2005實現的播放器http://download.csdn.net/detail/qaz2549066580/8261195 // MCI.h class MC

原创 用字符串常量做函數模板的參數

#include<iostream> #include<typeinfo> using namespace std; //參數以引用傳值 template<typename T> void ref(T const & x) { cout

原创 回調函數

在計算機程序設計中,回調函數,或簡稱回調(Callback 即call then back 被主函數調用運算後會返回主函數),是指通過函數參數傳遞到其它代碼的,某一塊可執行代碼的引用。這一設計允許了底層代碼調用在高層定義的子程序。

原创 socket實例

//先啓動服務器 //服務器 #include<winsock2.h> #include<stdio.h> #include<windows.h> #pragma comment(lib,"ws2_32") int main() {

原创 貪吃蛇遊戲代碼

/*改進版http://blog.csdn.net/qaz2549066580/article/details/41844639*/ #include<windows.h> #include<conio.h> #include<time

原创 非類型模板參數

模板參數不必都是類型,也可以是非類型的參數。 #include <iostream> using namespace std; template<int T> int add(int x) { return T+x; } int m

原创 Reduce EXE and DLL Size with LIBCTINY.LIB

http://msdn.microsoft.com/msdnmag/issues/01/01/hood/default.aspx  W ay back in my October 1996 column in MSJ, I a

原创 C語言實現二叉查找樹

#include <stdio.h> #include <stdlib.h> #include <time.h> typedef struct BiTree{ int data; struct BiTree *lch;

原创 C語言實現隊列

#include <stdio.h> #include <stdlib.h> #ifndef __cplusplus #include <stdbool.h> /*包含bool、true*/ #endif //__cplusplus

原创 MFC調用控制檯

MFC使用控制檯 AllocConsole(); // 爲調用進程分配一個新的控制檯 freopen("CONOUT$","w",stdout);

原创 C++分形樹繪製

/*參考孫博文的《分形算法與程序設計:Visual C++實現》*/   /*程序代碼,使用VC2005以上版本編譯*/ #include <Windows.h> #include <stdio.h> #include <stdlib.

原创 成員函數模板不能爲虛函數

#include<iostream> #include<typeinfo> using namespace std; template<typename T> class A{ public: virtual void beep(