- 博客(20)
- 资源 (1)
- 收藏
- 关注
原创 简单说下越界访问的调试方法
越界访问的一般提示是 “access violation reading location 0xXXXXXXXX”,翻译过来就是“内存越界访问”。这个提示和一般提示的不同之处是,程序不会停在越界访问的错误行上,而是会停在分配或释放内存的行上,于是就需要我们自己去找到越界行。那要怎么找到越界行呢?这里说一个较为实际的办法:首先根据 函数调用栈 (Call St
2016-11-06 22:15:59
3076
原创 级联继承中返回当前继承层类型的对象
// cascadederivationreturntypeofcurrentderivationlevel.cpp : Defines the entry point for the console application.//#include "stdafx.h"template class A{public: // 以下代码C2355 // 1 try //static
2016-04-25 23:49:54
364
原创 虚函数组实现虚级联继承 - 全开放和(接近)全闭合模式
// 全开放模式// virtualfunctionarrayrealizevirtualcascadederivation.cpp : Defines the entry point for the console application.//#include "stdafx.h"// 高级虚类class A_layer5{protected: virtual void f_
2016-04-25 23:38:02
500
原创 抽象基类运用与抽象基类指针作为模板容器元素
// abstractbasepointerastemplatecontainerelement.cpp : Defines the entry point for the console application.//#include "stdafx.h"// 模板容器template class vector{public: T m[10];};// 抽象基类clas
2016-04-25 23:35:43
534
原创 模板基类派生类的构造函数和析构函数
// constructorofclassderivedfromtemplateclass.cpp : Defines the entry point for the console application.//#include "stdafx.h"template class A{public: A() { } A(T c) { } A(A &a) { } ~
2016-04-25 23:33:46
2477
原创 多态的运用
// polymorphism.cpp : Defines the entry point for the console application.//#include "stdafx.h"class A{public: virtual void f() const { }};class B : public A{public: void f() const ove
2016-04-25 23:32:29
262
原创 C++编译器隐含规则
构造函数的调用:1. 在初始化时调用(构造函数)String str("some text.");2. 在类型转换时调用(转换构造函数)String str = String("some text.");3. 在隐式类型转换作传值函数实参时调用(隐式构造函数)void Print(String str){ printf("%s\n", str.m_str);}Print("
2016-04-25 23:31:23
266
原创 合成拷贝构造函数与拷贝构造函数初始化
// copyconstructor.cpp : Defines the entry point for the console application.//#include "stdafx.h"class A{public: A(){} ~A(){} int v;};class B{public: B(){} //B(B &b) : a(b.a) {} //
2016-04-25 23:26:51
1997
原创 转换构造函数和隐式构造函数
// converthiddenconstructor.cpp : Defines the entry point for the console application.//#include "stdafx.h"#include #include class String{public: // brief : 构造函数 // param : nil String() {
2016-04-25 23:25:37
1069
原创 重载算术运算符与重载赋值运算符
// overridearithmeticoperatorandoverrideassignoperator.cpp : Defines the entry point for the console application.//#include "stdafx.h"template class Matrix{public: // brief : 构造函数 // param :
2016-04-25 23:24:16
634
原创 重载赋值运算符
// overrideassignoperator.cpp : Defines the entry point for the console application.//#include "stdafx.h"template class Matrix{public: // brief : 构造函数 // param : nil Matrix(int row, int col
2016-04-25 23:22:54
291
原创 具有拷贝构造函数的类作形参
// classwithcopyconstructortobefunctionparameter.cpp : Defines the entry point for the console application.//#include "stdafx.h"class A{public: A() { } A(A &a) { } ~A() { }};void f(
2016-04-25 23:22:19
378
原创 具有内存分配的类的引用作形参
// referenceofclasswithnewoperatortobefunctionparameter.cpp : Defines the entry point for the console application.//#include "stdafx.h"class C{public: C() { str = new char; } ~C() { d
2016-04-25 23:20:50
299
原创 动态参数表作实参调用带动态参数表的函数
// doubledynamic.cpp : Defines the entry point for the console application.//#include "stdafx.h"#include // 动态参数列表作形参int dynamic(int c, char *str, ...){ int len = 0; for(int i = 0; i < c; i+
2016-04-25 23:17:31
372
原创 类成员函数返回值的引用
// classmemberfunctionreturnreference.cpp : Defines the entry point for the console application.//#include "stdafx.h"class C{public: int &member() { value = 1; return value; }public: i
2016-04-25 23:14:40
627
原创 简易函数指针
using namespace std;#include int f(){ return 0;}int function(int (*f)()){ return f();}int main(){ cout<<function(f);}
2016-04-25 23:12:49
224
原创 带动态参数表的函数
// functionthatwithdynamicparameterlist.cpp : Defines the entry point for the console application.//#include "stdafx.h"int ellipsis(...)// 动态参数表{ return 0;}int dynamic(int e, ...)// 动态参数表{
2016-04-25 23:11:34
323
原创 指针的引用作形参
// pointerreferenceasfunctionparameter.cpp : Defines the entry point for the console application.//#include "stdafx.h"#include "iostream"using namespace std;typedef struct pos{ int x; int y;
2016-04-25 23:07:23
688
原创 结构体的引用
// structurereference.cpp : Defines the entry point for the console application.//#include "stdafx.h"#include "iostream"using namespace std;typedef struct str{ int val; int x; int y;}pos;
2016-04-25 23:05:18
333
原创 函数指针作参数&运算符重载
// functionpointerparameterandoperator.cpp : Defines the entry point for the console application.//#include "stdafx.h"#include "iostream"using namespace std;typedef struct pos{ int x; int y;
2016-04-25 23:02:34
398
智能键盘(KeyDirect)
2014-07-07
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人