Things to Remember:在一個獨立的語句中將 new 出來的對象存入智能指標。如果疏忽了這一點,當異常發生時,可能引起微妙的資源泄漏。下面這個函數調用還是可能泄漏資源。為什嗎?processWidget(std::tr1::shared_ptr<Widget>(new Widget), priority()); 下面就來說明這是如何發生的。 在編譯器能產生一個對 processWidget
[轉載自: http://www.cppblog.com/szhoftuncun/archive/2007/10/31/35356.html]#pragma once與 #ifndef的區別 Specifies that the file will be included (opened) only once by the compiler when compiling a source code file. 1 #ifndef方式2 #pragma
1. Multibyte shows to us as char*. While in fact, it can be any code page encoding, including gbk, utf8, etc. If a char* represents utf8 characters, we need to handle it specially in below way:// Convert unicode(windows default utf16) to utf8 char*
An exception is an event that occurs during the execution of a program, and requires the execution of code outside the normal flow of control. There are two kinds of exceptions: hardware exceptions and software exceptions. Hardware exceptions
Essence: Wrap functions to read/write things from another module. Windows keep seperate heaps for debug and release - built DLLs and EXEs. So for example, calling a release DLL from a debug application EXE, any memory we allocate needs to be
文章目錄 Problem [http://www.gotw.ca/gotw/054.htm]另可以參考:http://blog.csdn.net/zzpzheng/archive/2006/03/27/639876.aspx Using Vector and Deque Difficulty: 8 / 10What is the difference between vector and deque? When should you
For the details on how to initialize a GUID, check this page http://support.microsoft.com/kb/130869. (definitely we are using a new version compiler! So get to use #include<initguid.h>)Summary of a problem I met and finally find the above
Manifests are XML files that accompany and describe side-by-side assemblies or isolated applications. Manifests uniquely identify the assembly through the assembly's <assemblyIdentity> element. They contain information used for binding and
static_cast:強制類型轉換cast。因此,當然可以用於有繼承關係的類之間的cast,細分有三類:upcast:Just same as dynamic_cast. 由於不用做runtime類型檢查,效率比dynamic_cast高;downcast:不安全得很。不建議使用。crosscast:不能用。帶來編譯錯誤。dynamic_cast:有繼承關係的類之間的cast。非常安全,但是由於需要做runtime類型檢查,並且需要virtual
Get it from: http://msdn.microsoft.com/zh-cn/magazine/cc188714(en-us).aspxIn one word, in order to use STL string to be adaptive with Unicode, the best way is to define a tstring as follows:#include<string>#ifdef _UNICODE#define tstring
From MSDN:To simplify code development for various international markets, the Microsoft run-time library (CRT) provides Microsoft-specific "generic-text" mappings for many data types, routines, and other objects. These mappings are defined in
Visual Studio Solution[MSDN: http://msdn.microsoft.com/en-us/library/bb165922(VS.80).aspx]Overview of Solutions A solution is a grouping of one or more projects that work together to create an application. The project and status information that
[Copied From C++ Coding Standards--chapter 8] We define premature optimization as making designs or code more complex, and so less readable, in the name of performance when the effort is not justified by a proven performance need (such as actual
[Copied from C++ coding standards-chapter 9] Easy on yourself, easy on the code: All other things being equal, notably code complexity and readability, certain efficient design patterns and coding idioms should just flow naturally from your
MFC Library Reference[MSDN: http://msdn.microsoft.com/zh-cn/library/0asx94f7(VS.80).aspx] Managing the State Data of MFC ModulesThis article discusses the state data of MFC modules and how this state is updated when the flow of execution (the path
CString::LoadString(UINT nID)Conclusion: the correct way to load string resource by ID is to call CString::LoadString(HINSTANCE hInstance,UINT nID), specifying the dll handler you want to search for.ProblemCString::LoadString(UINT nID) will first