原创 指針的引用作形參

// pointerreferenceasfunctionparameter.cpp : Defines the entry point for the console application. // #include "stdafx.

原创 簡易函數指針

using namespace std; #include <iostream> int f() { return 0; } int function(int (*f)()) { return f(); } int main()

原创 C++編譯器隱含規則

構造函數的調用: 1. 在初始化時調用(構造函數)String str("some text.");2. 在類型轉換時調用(轉換構造函數)Strin

原创 簡單說下越界訪問的調試方法

越界訪問的一般提示是 “access violation reading location 0xXXXXXXXX”,翻譯過來就是“內存越界訪問”。 這個提示和一般提示的不同之處是,程序不會停在越界訪問的錯誤行上, 而是會停在分配或釋放內

原创 抽象基類運用與抽象基類指針作爲模板容器元素

// abstractclass.cpp : Defines the entry point for the console application. // #include "stdafx.h" #include <vector>

原创 虛函數組實現虛級聯繼承 - 全開放和(接近)全閉合模式

// 全開放模式 // virtualfunctionarrayrealizevirtualcascadederivation.cpp : Defines the entry point for the console applicati

原创 級聯繼承中返回當前繼承層類型的對象

<pre name="code" class="plain">// cascadederivationreturntypeofcurrentderivationlevel.cpp : Defines the entry point for

原创 合成拷貝構造函數與拷貝構造函數初始化

// copyconstructor.cpp : Defines the entry point for the console application. // #include "stdafx.h" class A { public

原创 多態的運用

// polymorphism.cpp : Defines the entry point for the console application. // #include "stdafx.h" class A { public:

原创 具有內存分配的類的引用作形參

// referenceofclasswithnewoperatortobefunctionparameter.cpp : Defines the entry point for the console application. //

原创 具有拷貝構造函數的類作形參

// classwithcopyconstructortobefunctionparameter.cpp : Defines the entry point for the console application. // #includ

原创 結構體的引用

// structurereference.cpp : Defines the entry point for the console application. // #include "stdafx.h" #include "iost

原创 模板基類派生類的構造函數和析構函數

// constructorofclassderivedfromtemplateclass.cpp : Defines the entry point for the console application. // #include "

原创 類成員函數返回值的引用

// classmemberfunctionreturnreference.cpp : Defines the entry point for the console application. // #include "stdafx.h

原创 重載算術運算符與重載賦值運算符

// overridearithmeticoperatorandoverrideassignoperator.cpp : Defines the entry point for the console application. // #