随笔分类 - C++
摘要:参考资料: 1. 《C++编程思想(第一卷)》 知识点: ● register变量:它是一种局部变量类型。它告诉编译器尽快访问该变量。一般会把变量放在寄存器中,但不保证一定会。不能得到或计算寄存器变量的地址,且寄存器变量必须在模块中声明。无全局或静态寄存器变量。 注意:要相信编译器,尽量避免使用re
阅读全文
摘要:1.WxWidgets2. GTK+3. U++ Framework4. QT
阅读全文
摘要:http://blog.chinaunix.net/uid-7186957-id-2677935.html
阅读全文
摘要:Decay即数组在某些情况下将退化为指针。测试代码:#include #include template void ref (T const& x){ std::cout void nonref(T x){ std::cout << "x in nonref(T): " << typei...
阅读全文
摘要:注意:函数模板不支持模板的模板参数。Stack7.h中定义的Stack:#ifndef STACK7_H#define STACK7_H#include #include #include template > class CONT = std::deque>class Stack{...
阅读全文
摘要:函数模板特化必须在实例化之前。成员模板函数(MTF)的特化必须在类外,不能使用内联(inline)进行特化。浮点数、类对象(class-type)、内部链接对象(如字符串常量"Hello World",注意:extern char const s[] = "hello"外部链接对象则可以)和全局指针...
阅读全文
摘要:function3.h中的代码:#ifndef FUNCTION3_H#define FUNCTION3_H#include #include #include template T myMax(const T p1, const T p2){ std::cout int myMax(int ...
阅读全文
摘要:函数的定义function2.h:#ifndef FUNCTION2_H#define FUNCTION2_H#include #include #include template T myMax(const T p1, const T p2){ std::cout const char* m...
阅读全文
摘要:模板函数定义文件function1.h:#ifndef FUNCTION1_H#define FUNCTION1_H#include #include template inline T const& max(T const&a , T const& b){ return a inline T...
阅读全文
摘要:Stack4.hpp的代码如下:#ifndef STACK4_HPP#define STACK4_HPP#include #include #include template class Stack{public: Stack(); void push(T const&); voi...
阅读全文
摘要:Stack3.h的内容如下:#ifndef STACK3_H#define STACK3_H#include #include #include template >class Stack{private: CONT elems;public: void push(T const&);...
阅读全文
摘要:MyClass.h文件代码:#ifndef MYCLASS_H#define MYCLASS_H#includetemplate class MyClass{public: void print() { std::cout class MyClass{public: ...
阅读全文
摘要:特化的目的: 表明该模板在特殊类型下具有不同的行为。注意:特化的实现可以和基本类模板的实现完全不同。Stack2.h代码:#ifndef STACK2_H#define STACK2_H#include #include #include #include "TestCC.h"templatecla...
阅读全文
摘要:以下是一个Stack的模板实现类,注意GCC不支持将模板类的声明和定义分开放(普通类支持):TestCC.h文件的内容:#ifndef TESTCC_H#define TESTCC_H#include #include #include template class Stack{private: ...
阅读全文
摘要:下边代码对new和delete进行了简单的重载:#include #include #include using namespace std;class TraceHeap{ int i;public: static void* operator new(size_t siz) {...
阅读全文
摘要:拷贝构造函数从其名字上可得到两个信息:一是它是一个构造函数(它的用途),二是它是通过拷贝实现构造函数的功能的(如何实现)。 在《深度探索C++对象模型》一书中,对拷贝构造函数的调用情况进行了详细的讲述,书中记载共三种情况。但这三种情况的本质是“用一个既存对象去初始化另一个对象”。 而赋值运算...
阅读全文
摘要:1 //============================================================================ 2 // Name : CopyInts4.cpp 3 // Author : motein 4 // Vers...
阅读全文


浙公网安备 33010602011771号