Time of Update: 2018-12-05
調用erase()移除map中的元素,《C++標準程式庫》提供了一個樣本,在此記錄以下:#include <iostream>#include <map>#include "print.hpp"int main(){std::map<int, int> col1;col1.insert(std::make_pair(1, 1));col1.insert(std::make_pair(2, 2));PRINT_ELEMENTS2(col1, "before
Time of Update: 2018-12-05
1、如果安裝的系統沒有帶gcc,需要到www.sunfreeware.com下載針對於Solaris 10 的gcc,先選SPARC/Solaris 10 或x86/Solaris 10,看你的系統是SPARC 還是X86而定,再選gcc-3.4.6,下載以下兩個包,gcc-3.4.6-sol10-sparc-local.gz、libiconv-1.11-sol10-sparc-local.gz 2、用以下命令安裝: $gunzip
Time of Update: 2018-12-05
本文簡單介紹一下基於對話方塊的MFC應用程式的按鍵捕獲和處理。 如下所示,捕獲escape按鍵動作,然後直接返回不處理(正常情況下,該按鍵會導致OnClose()處理。BOOL CSugDlg::PreTranslateMessage(MSG* pMsg) {// TODO: Add your specialized code here and/or call the base classif (pMsg->message == WM_KEYDOWN){if
Time of Update: 2018-12-05
參考百度知道:http://baike.baidu.com/view/1186290.htmC語言庫函數函數功能:搜尋與指定的檔案名稱匹配的第一個執行個體,若成功則返回第一個執行個體的控制代碼,否則返回-1L函數原型:long _findfirst( char *filespec, struct _finddata_t *fileinfo );標頭檔:io.h普通用法:#include<io.h>#include<stdio.h>int main(){ long
Time of Update: 2018-12-05
環境:VS 2003.NET + Visual Assit X 10.5.1715.0常用快速鍵列舉:1,Ctrl+Shift+S 開啟FindSymbol對話方塊該快速鍵若失效,請參考以下文章解決:http://blog.csdn.net/vivianke/article/details/74322982,Ctrl+Shift+O 開啟Open File In Solution對話方塊3,Alt+<- 回退到上一個游標處4,選中一個符號Alt+G,開啟Goto
Time of Update: 2018-12-05
摘要: ListView_SetItemState能設定ListView控制項的item選中狀態資訊,例如選中,擷取焦點等函數原型:ListView_SetItemState( HWND hwnd, int i, UINT state, UINT mask);樣本設定IDC_LIST_OTHER列表視圖控制項的選中狀態碼:ON_NOTIFY(NM_CLICK, IDC_LIST, OnClickList)void CDlg::OnClickList(NMHDR*
Time of Update: 2018-12-05
當MFC ClassWizard中Class name列表中,若沒有已經添加到工程的視窗類別,可以通過以下方式添加:1, 在工程的CLW檔案中添加CDlgShow類索引,如下:[General Info]ClassCount=4Class1=CCustomWizardAppClass2=CCustomWizardDlgClass3=CAboutDlgClass4=CDlgShow然後,在工程中,再次開啟View->ClassWizard類嚮導,然後選中Class
Time of Update: 2018-12-05
設定三個自訂工具菜單:PC-lintPC-lint(Single)Create Lint File每個路徑對應對應三個輸入項: Command Arguments Initial directory依次如下:PC-lint:Command c:\lint\lint-nt.exeArguments +ffn -i"c:\lint" -u std_nt.lnt $(WkspName).lntInitial directory $(WkspDir)選中User
Time of Update: 2018-12-05
ubuntu下的C++的字串hash函數:inline size_t __stl_hash_string(const char* __s){unsigned long __h = 0; for ( ; *__s; ++__s) __h = 5*__h + *__s;return size_t(__h);}VS 2003.NET的stl內建的hash函數:template<class _Elem,class _Traits,class _Alloc> inlinesize_t
Time of Update: 2018-12-05
關注點:__attribute__機制,用於聲明,而不是定義,並且其位置約束為放於聲明的尾部“;”之前。 對於__attribute__((constructor和(destructor)) ,用法一:void before_main() __attribute__((constructor));void before_main(){ printf("before main\n");}void after_main() __attribute__((constructor));void
Time of Update: 2018-12-05
部落格轉移:http://vivianke.blog.163.com/blog/static/29715271200781121358317/ 說明:1.CStatic控制項背景透明,要首先從CStatic派生一個類,在這個類中,afx_msg HBRUSH CtlColor(CDC* pDC, UINT nCtlColor)是反射函數,該函數處理=WM_CTLOLOR訊息,訊息映射宏為:ON_WM_CTLCOLOR_REFLECT(),2.afx_msg HBRUSH
Time of Update: 2018-12-05
參考《程式員的自我修養—連結、裝載與庫》一書,4.5節Visual C++ 也提供了與Linux下的ar類似的工具,叫lib.exe,這個程式可以用來建立、提取、列舉.lib檔案中的內容。樣本:首先需要將X:\Program Files\Microsoft Visual Studio\VC98\Bin\;X:\Program Files\Microsoft Visual Studio\Common\MSDev98\Bin\;添加到環境變數中並在X:\Program
Time of Update: 2018-12-05
電子書《精通DirectX.3D圖形與動畫程式設計.王德才.pdf》p54對頂點緩衝區的記憶體操作,必須通過Lock和Unlock來實現以下介紹Lock函數HRESULT Lock( [in] UINT OffsetToLock, [in] UINT SizeToLock, [out] VOID **ppbData, [in] DWORD Flags);OffToLock 指定加鎖記憶體起始地址SizeToLock指定加鎖記憶體大小ppbData
Time of Update: 2018-12-05
intACE_Event_Handler::handle_close (ACE_HANDLE,
Time of Update: 2018-12-05
電子書《精通DirectX.3D圖形與動畫程式設計.王德才.pdf》p53HRESULT CreateVertexBuffer( UINT Length, DWORD Usage, DWORD FVF, D3DPOOL Pool, IDirect3DVertexBuffer9** ppVertexBuffer, HANDLE* pSharedHandle);Length: 指定緩衝區的大小,以位元組為單位。Usage: 指定頂點緩衝區的屬性,可以設定成0:
Time of Update: 2018-12-05
代碼:#include <stdio.h>int main(){ int a = 0x414243; printf("0x%x\n", a); return 0;}大端樣本:平台:AIX aix 3 5 00C97AC04C00 powerpc unknown AIXBreakpoint 1, main () at test-endian.cpp:55 int a = 0x414243;(gdb) n7 printf("0x%
Time of Update: 2018-12-05
最近項目中要使用stl中的hash_map,開發工具VS 2003.NET。hash_map不是標準的stl容器,但是在VS2003中,仍舊可以這樣使用:#include <hash_map>...std::hash_map<int, int> col1;for (int i = 0; i < 100000; ++i) {col1.insert(std::make_pair(i, i));}但是編譯的時候會有Warning,如下: warning C4996:
Time of Update: 2018-12-05
代碼:#include <stdio.h>int main(){ int a = 0x414243; printf("%d\n", 1); return 0;}to compile and link:xlC_r -g -o test test.cppto debug:dbx ./test Type 'help' for help.reading symbolic information ...(dbx)
Time of Update: 2018-12-05
根據《C++標準程式庫》中描述,對於map的find()成員函數,可以用來搜尋擁有某個key的第一個元素,但是不能搜尋持有某特定value的元素。如果搜尋某特定value,需要使用find_if(),或者迴圈遍曆。以下樣本如何使用find_if():#include <iostream>#include <map>#include <string>#include <algorithm>typedef
Time of Update: 2018-12-05
簡單樣本CListCtrl的事件處理1,NM_DBLCLK(NM_CLICK類似)void CTestDlg::OnDblclk(NMHDR* pNMHDR, LRESULT* pResult) {// TODO: Add your control notification handler code hereLPNMITEMACTIVATE lpNMItem = (LPNMITEMACTIVATE) pNMHDR;int nItem = lpNMItem->iItem;if