Time of Update: 2018-12-07
原文連結盡量用const和inline而不用#define也稱為:盡量用編譯器而不用預先處理。原因:(1)#define ASPECT_RATIO 1.653 編譯前預先處理程式會將ASPECT_RATIO 替換為1.653,編譯出錯時只會指出1.653,而無法跟蹤ASPECT_RATIO,不便於調試(2)#define max(a,b) ((a) > (b) ? (a) : (b))有可能出錯:int a = 5, b = 0;max(++a, b);// a 的值增加了2次max(++
Time of Update: 2018-12-07
stl string 使用1. 尋找字元std::wstring strData = L"<result>[北京市, 上海市, 深圳市]</result>"void DoF(const std::wstring &strData, std::list<std::wstring>& listDo){ std::wstring strTarB = L"<result>["; std::wstring strTarE =
Time of Update: 2018-12-07
原文連結class類中預設會實現4個函數,分別為預設建構函式,拷貝建構函式,解構函式和=運算子多載 #include <iostream>using namespace std;class myString{ public: myString(const char *str=NULL); myString(const myString &other); ~myString(); myString &
Time of Update: 2018-12-07
原文地址:http://blog.csdn.net/nhczp/article/details/1862695本文主要討論以下幾方面的設定:1.字型2.cedet3.ecb4.cscope5.gdb-many-window6.行號7.縮排 環境:openSUSE 10.2預設裝的是Emacs 21,我從網上下了Emacs 22.1的tar包,編譯安裝。1.字型 預設的字型非常之小,以下是一篇非常詳細的Emacs下設定字型的教程http://www.yuanma.org/data/2006/
Time of Update: 2018-12-07
大家都希望可以像操作STL容器一樣的去運算元組,C++可沒有提供這個東西,有時候你會選擇使用vector來替代,不過這畢竟不是個好的辦法,畢竟vector類比動態數組比較穩妥,而用它去替代一個普通的數組,開銷畢竟太大了。而恰好,boost::array就為你提供了這個功能。boost::array的定義如下(簡化):詳情參見相關檔案Code highlighting produced by Actipro CodeHighlighter
Time of Update: 2018-12-07
原文地址:http://blog.csdn.net/hide1713/article/details/1647209更多圖片請看http://ecb.sourceforge.net/先下載這兩個軟體的安裝包ecb http://ecb.sourceforge.net/cedet http://cedet.sourceforge.net/然後tar zxvf ecb-2.32.tar.gzcd cedet-1.0pre4make (ecb需要設定Makefile
Time of Update: 2018-12-07
原文地址:http://hi.baidu.com/study_together/blog/item/f14cb83319f70d94a8018e3e.html編譯:編譯:gcc -g -Wall -O0 fuck.c -o fuck `pkg-config --libs --cflags glib-2.0`1基本操作這裡是使用 GList 可以進行的一些常見操作:#include <glib.h>#include <stdio.h>int main(int argc,
Time of Update: 2018-12-07
多線程執行個體 :lp.c#include <pthread.h>#include <stdio.h>#include <sys/time.h>#include <string.h>#define MAX 10pthread_t thread[2];pthread_mutex_t mut;int number=0, i;void *thread1(){ printf ("thread1 : I'm thread 1\n");for (i =
Time of Update: 2018-12-07
原文連結:http://blog.csdn.net/wxw45601/article/details/7668499參考連結:http://wenku.baidu.com/view/970280c45fbfc77da269b1f5.html在編程過程中,我們習慣把資料作為參數傳遞給方法(例:int
Time of Update: 2018-12-07
1,字串 到 數實值型別的轉換 2,數值 到 字串的轉換 3,異常處理情況 4,boost::lexical_cast 的原型: template<typename Target, typename Source> Target lexical_cast(Source arg); lexical_cast 是依賴於字串流 std::stringstream 的,其原理也是相當的簡單:把源類型 (Source) 讀入到字元流中,再寫到目標類型 (Target)
Time of Update: 2018-12-07
多線程執行個體2:#include <stdio.h> #include <stdio.h>#include <pthread.h>void thread(void) {
Time of Update: 2018-12-07
boost, asio, SPServer boost::asio是一個高效能的網路開發庫,Windows下使用IOCP,Linux下使用epoll。與ACE不同的是,它並沒有提供一個網路架構,而是採取組件的方式來提供應用介面。但是對於常見的情況,採用一個好用的架構還是能夠簡化開發過程,特別是asio的各個非同步介面的用法都相當類似。 受到 SP Server 架構的影響,我使用asio大致實現了一個多線程的半非同步半同步伺服器架構,以下是利用它來實現一個Echo伺服器:1. 實現回調:
Time of Update: 2018-12-07
以前使用ACE實現Server架構,但是覺得太笨重,決定採用boost.asio來寫伺服器程式: 1.伺服器構建在linux上面;當然也可以在windows下運行 2.io部分採用非阻塞模式、商務邏輯部分採用同步線程池實現 3.封裝io操作及狀態,使用者應用程式無需關心io詳細操作所以決定採用boost::asio架構來寫伺服器:boost::asio::io_service提供了核心IO功能、和非同步IO對象,它包括: boost::asio::ip::tcp::socket
Time of Update: 2018-12-07
http://code.google.com/p/goog-maps-demo/source/browse/trunk/examples/Map/fitBounds.html?r=6http://www.tongmap.cn/code/webgis3.0--API/symbols/sic.LatLngBounds.html1 var geocoder = new google.maps.Geocoder(); //地圖搜尋對象geocoder.geocode( { 'address':
Time of Update: 2018-12-07
參考地址:http://code.google.com/intl/zh-CN/apis/maps/documentation/javascript/examples/marker-simple.html<!DOCTYPE html><html><head><meta name="viewport" content="initial-scale=1.0, user-scalable=no" /><meta
Time of Update: 2018-12-07
原文地址:http://cgxcn.blog.163.com/blog/static/1323124220095384043365/js 正則匹配(去掉html標籤)1,得到網頁上的連結地址:string matchString =
Time of Update: 2018-12-07
文章目錄 所需標頭檔:範例程式碼: boost::format類提供了類似C語言裡'printf'功能的格式化輸出能力,當然功能更強大。所需標頭檔:#include <boost/format.hpp>範例程式碼:#include <iostream> #include <string> #include <boost/format.hpp> using namespace std;
Time of Update: 2018-12-07
參考地址:http://code.google.com/intl/zh-CN/apis/maps/documentation/javascript/examples/index.html<!DOCTYPE html><html><head><meta name="viewport" content="initial-scale=1.0, user-scalable=no"/><meta http-equiv="content-type"
Time of Update: 2018-12-07
boost::scoped_ptr雖然簡單易用,但它不能共用所有權的特性卻大大限制了其使用範圍,而boost::shared_ptr可以解決這一局限。顧名思義,boost::shared_ptr是可以共用所有權的智能指標,首先讓我們通過一個例子看看它的基本用法: #include <string>#include <iostream>#include <boost/shared_ptr.hpp>class implementation{public: ~
Time of Update: 2018-12-07
使用情景:當類對象被 shared_ptr 管理時,需要在類自己定義的函數裡把當前類對象作為參數傳給其他函數時,這時需要傳遞一個 shared_ptr ,否則就不能保持 shared_ptr 管理這個類對象的語義(因為有一個 raw pointer 指向這個類對象,而 shared_ptr 對類對象的這個引用沒有計數,很有可能 shared_ptr 已經把類對象資源釋放了,而那個調用函數還在使用類對象——顯然,這肯定會產生錯誤)。很好奇這個模板類的實現。先看看怎麼使用:對一個類 A