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
char string[1]; // string[10] is the boundary example to tell the extra '0' in a c style string will also be copied when copying.char *str1="0123456789";strcpy(string, str1); // 11 char will be copied to the destination memory.Running above sample
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
VS project property sheet As projects in a solution grow more and more, the project setting management will be more and more complicated. Modifying one by one will be hard work and easy to cause mistakes. Luckily, VS has already provides us a way to
文章目錄 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
You may meet below errors before:error C2220: warning treated as error - no 'object' file generated warning C4819: The file contains a character that cannot be represented in the current code page (936). Save the file in Unicode format to prevent
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
1. Use _CrtDumpMemoryLeaks() to check whether there is memory leak in program. With the help of _CRTDBG_MAP_ALLOC, it can output memory leak info with file line info for those memory block allocated by malloc(), while it would never print file line
一句話總結:DllMain函數是dll的entry point。但是,有兩種dll可以不用帶dllmain函數:一種自然是資源dll;另一種是dll不需要在entry point做什麼事情,所以不寫了乾脆。但是系統在往進程裡載入一個dll的時候,一定會去找dllmain的。如果dll本身沒有提供,那麼會調用一個預設的(應該是CRT的)dllmain函數。MSDN上的話:DllMain Callback FunctionAn optional entry point into a dynamic-
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
文章目錄 Comments [VCBlog Link: http://blogs.msdn.com/vcblog/archive/2008/05/15/vc-runtime-binding.aspx]VC Runtime Binding...Hello, I am George Mileka, a developer on the Visual C++ Libraries Team. After we released the
文章目錄 To edit a loaded project file in Visual Studio [From: http://msdn.microsoft.com/en-us/library/ms171487(VS.80).aspx] Visual StudioHow To: Edit Project Files MSBuild project files are written in a standard XML format,