C++
文章平均质量分 65
g1lder
这个作者很懒,什么都没留下…
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
函数指针作参数&运算符重载
// 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 · 422 阅读 · 0 评论 -
级联继承中返回当前继承层类型的对象
// 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 · 379 阅读 · 0 评论 -
虚函数组实现虚级联继承 - 全开放和(接近)全闭合模式
// 全开放模式 // 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 · 528 阅读 · 0 评论 -
模板基类派生类的构造函数和析构函数
// 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 · 2508 阅读 · 0 评论 -
多态的运用
// 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 · 287 阅读 · 0 评论 -
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 · 289 阅读 · 0 评论 -
合成拷贝构造函数与拷贝构造函数初始化
// 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 · 2019 阅读 · 0 评论 -
转换构造函数和隐式构造函数
// 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 · 1098 阅读 · 0 评论 -
重载算术运算符与重载赋值运算符
// 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 · 688 阅读 · 0 评论 -
重载赋值运算符
// 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 · 317 阅读 · 0 评论 -
具有拷贝构造函数的类作形参
// 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 · 405 阅读 · 0 评论 -
具有内存分配的类的引用作形参
// 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 · 316 阅读 · 0 评论 -
动态参数表作实参调用带动态参数表的函数
// 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 · 394 阅读 · 0 评论 -
类成员函数返回值的引用
// 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 · 651 阅读 · 0 评论 -
简易函数指针
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 · 241 阅读 · 0 评论 -
带动态参数表的函数
// 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 · 347 阅读 · 0 评论 -
指针的引用作形参
// 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 · 713 阅读 · 0 评论 -
结构体的引用
// 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 · 367 阅读 · 0 评论 -
抽象基类运用与抽象基类指针作为模板容器元素
// 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 · 579 阅读 · 0 评论
分享