繼承和抽象類別中提到過,子類與父類的方法間有這些關係:子類直接使用父類方法(但是必須父類方法是public或protected類型);子類的方法覆蓋父類方法(override);子類的方法重載父類方法(overload);看下面這種情況: public class YSchool { private int id = 0; private string name = string.Empty; public int ID {
A Template for C-Language Library Creation一個建立C語言運行庫的模板We suppose the library we want to create is libElec.1)Create a folder in your disk, such as D:/libElec2)Create a sub-directory in D:/libElec, such as D:/libElec/src. We put all codes files in
動態數組 本文實現了可以儲存固定大小資料的動態數組.動態數組就是在記憶體中分配連續的地區,儲存固定大小的結構數組。並能根據插入或刪除的值,自動調節大小。類似std::vector。但本文採用C語言實現。 /********************************************************************** * darray.h - Dynamic array for any type data * *****
C++ DLL 模板1、使用VS2005建立Win32 DLL項目,選擇空項目,然後加入CppDll.h和CppDll.cpp檔案。2、修改CppDll.h和CppDll.cpp檔案使之成為需要的內容。3、編譯產生CppDll.dll。下面是模板檔案://// CppDll.h// by cheungmine// C++ DLL 模板///*** 使用CPPDLL:#include "../CppDll.h"#ifdef _DEBUG# pragma comment(lib,
自己寫的字串去除空格C函數1) 在字串s中剔出指定的字元cstatic char* trim(char *s, char c){ return (*s==0)?s:(((*s!=c)?(((trim(s+1,c)-1)==s)?s:(*(trim(s+1,c)-1)=*s,*s=c,trim(s+1,c))):trim(s+1,c)));}例子:char str[] = " M y B eautiful C hin a ! ";char *s = trim(str, 32);+
CppCMS的編譯和使用請參考我的相關文章。將C++對象轉換成JSON字串假定有一個類response,兩個欄位,一個是status,0代表正確。其他代表錯誤。另一個是message欄位,表示操作結果的具體資訊。代碼如下:class response {public: //0 is ok //other values are wrong int status; string
google c++編碼規範很全面,現在已經逐漸習慣了這種編碼規範,突然想到或許emacs中有合適的el支援這種規範,到網上一找,果然有。http://google-styleguide.googlecode.com/svn/trunk/google-c-style.el下載下來,放在emacs.d目錄下,然後在.emacs設定檔中添加幾行:(add-to-list 'load-path (expand-file-name "~/.emacs.d"))(require