분류 전체보기
-
반복자 클래스제네릭 프로그래밍 2009. 1. 7. 23:24
두 개의 반복자가 동일한 연산을 지원한다면, 그 두 연산의 이름은 같다. 입력 반복자(input iterator) 순차적 읽기 전용 접근 .==() .!=() .++() .*() // 읽기 .->() #include vector v; copy(istream_iterator(cin), istream_iterator(), back_inserter(v)); 출력 반복자(output iterator) 순차적 쓰기 전용 접근 write-once ( single-assignment ) ++() .*() // 쓰기 std::back_inserter #include ... copy(v.begin(), v.end(), ostream_iterator(cout, " ")); 순방향 반복자(forward iterator) 순..
-
클래스 템플릿제네릭 프로그래밍 2009. 1. 7. 19:48
멤버 템플릿 함수도 정의할 수 있다. #ifdef _MSC_VER #pragma warning( disable: 4786 ) #endif #include #include using namespace std; template class BinaryTree; template class BTnode; template ostream& foo( ostream &os, const BTnode &bt ); template class BTnode { friend class BinaryTree; friend ostream& // foo( ostream&, const BTnode& ); foo( ostream&, const BTnode& ); public: BTnode( const valType &val ); const ..
-
연관 배열 - STLData/Container 2009. 1. 5. 15:18
연관 배열 std::map .count() .[]() .find() .erase() ::iterator .begin() .end() vector와는 달리 인덱스가 정수일 필요가 없다. #include #include #include int main(int argc, char* argv[]) { using namespace std; map directory; directory["Bogart"] = 1234567; directory["Bacall"] = 9876543; ... // Read some names and look up their numbers: string name; while (cin >> name) if (directory.find(name) != directory.end()) cout
-
MS FlexGrid(MSFlexGrid)GUI/컨트롤 2009. 1. 5. 13:55
CMSFlexGrid .SetRows() .SetCols() .SetTextMatrix() .SetRow() .SetCol() .SetCellBackColor() .SetCellForeColor() CEditFlexGrid -> CMSFlexGrid #include "EditFlexGrid.h" class CEditableGridDlg : public CDialog { // Construction public: CEditableGridDlg(CWnd* pParent = NULL); // standard constructor // Dialog Data //{{AFX_DATA(CEditableGridDlg) enum { IDD = IDD_EDITABLEGRID_DIALOG }; CEditFlexGrid m_..
-
리스트 박스 - Win32GUI/컨트롤 2009. 1. 4. 16:59
로그 표시 CreateWindow() "listbox" WS_VSCROLL LBS_NOTIFY LBS_EXTENDEDSEL LBS_MULTIPLESEL LBS_WANTKEYBOARDINPUT // WM_VKEYTOITEM on LBN_SELCHANGE on WM_VKEYTOITEM on LBN_DBLCLK LB_ADDSTRING LB_DELETESTRING LB_ITEMFROMPOINT LB_SETCURSEL LB_GETCURSEL LB_GETTEXT LB_GETTOPINDEX LB_SETTOPINDEX LB_GETITEMHEIGHT LB_RESETCONTENT LB_GETCOUNT DlgDirList() // LB_DIR DlgDirSelectEx() LB_FINDSTRING LB_FINDSTRINGE..
-
트리 컨트롤 - Win32GUI/컨트롤 2009. 1. 3. 18:11
LRESULT OnCreate(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/) { RECT rc; GetWindowRect(&rc); rc.right -= rc.left; rc.bottom -= rc.top; rc.top = rc.left = 0; InitCommonControls(); // { m_ctlSysTreeView32.Create(m_hWnd, rc, NULL, WS_VISIBLE | WS_CHILD | TVS_LINESATROOT | TVS_HASLINES | TVS_EDITLABELS | TVS_HASBUTTONS | TVS_FULLROWSELECT | TVS_SHOWSELALWAYS, WS_EX_CLIENT..
-
C++프로그래밍 언어/expression 2009. 1. 3. 15:32
reinterpret_cast() 임의의 데이터 형식을 전혀 다른 임의의 데이터 형식으로 바꾼다. HTREEITEM hRoot = reinterpret_cast(m_ctlSysTreeView32.SendMessage(TVM_INSERTITEM , 0, reinterpret_cast(&TreeCtrlItem))); /* or HTREEITEM hRoot = (HTREEITEM)(m_ctlSysTreeView32.SendMessage(TVM_INSERTITEM , 0, (LPARAM)(LPTVINSERTSTRUCT)(&TreeCtrlItem))); */ static_cast() 런타임시에 발생할 수 있는 오류를 컴파일 타임에 잡아내 줄수 있다. c type의 cast는 버그의 가능성을 만들어 주지만 stat..