码迷,mamicode.com
首页 >  
搜索关键字:operator overloading    ( 3732个结果
C++必知必会(4)
条款35 placement new 直接调用构造函数是行不通的,然而可以通过使用placement new来哄骗编译器调用构造函数: void *operatornew(size_t, void* p) throw() { return p;} placement new是operator new的一个标准的重载版本,也位于全局名字空间中,但和我们通常看到的operator new不同,...
分类:编程语言   时间:2014-06-05 09:20:32    阅读次数:315
const经典例子小结
在看这个例子之前,可以先看看:详解C和C++中的const和const和static变量的存放位置这样将会对const有非常全面的了解和认识: 下面我们将通过下面的例子看看const的一些非常不易发觉的错误: #include using namespace std; class String { public: friend ostream& operator<<(ostream& os...
分类:其他好文   时间:2014-06-05 02:53:26    阅读次数:273
条款11:在operator = 中处理"自我赋值"
条款11:在operator = 中处理"自我赋值"...
分类:其他好文   时间:2014-06-04 21:01:03    阅读次数:287
每日算法之二十五:Divide Two Integers
Divide two integers without using multiplication, division and mod operator. 不使用乘法、除法和求模运算求两个数相除。...
分类:其他好文   时间:2014-06-01 18:16:23    阅读次数:311
一个自增与自减的源码
#include using namespace std; //template class Int {     friend ostream& operator public:     Int(int i):m_i(i)     {     }     Int& operator++()     {         ++(this->m_i);         r...
分类:其他好文   时间:2014-06-01 09:00:22    阅读次数:209
poj 1094 Sorting It All Out
DescriptionAn ascending sorted sequence of distinct values is one in which some form of a less-than operator is used to order the elements from smalle...
分类:其他好文   时间:2014-05-30 14:31:10    阅读次数:297
vc 报error LNK2005的处理
昨天编译一个小程序的时候,报了个错,或者说2个 1>uafxcw.lib(dllmodul.obj) : error LNK2005: _DllMain@12 已经在 LIBCMT.lib(dllmain.obj) 中定义 1>uafxcw.lib(afxmem.obj) : error LNK2005: "void __cdecl operator delete(void *)" (??3@...
分类:其他好文   时间:2014-05-26 03:18:48    阅读次数:200
Effective C++ Item 10 令operator= 返回一个reference to *this
经验:令赋值(assignment)操作符返回一个reference to *this --》 这样可以实现级联赋值...
分类:编程语言   时间:2014-05-25 13:33:44    阅读次数:286
Effective C++ Item 11 在operator= 中处理“自我赋值”
经验:确保当对象自我赋值时operator=有良好行为。其中技术包括比较“来源对象”和“目标对象”的地址、精心周到的语句顺序、以及copy-and-swap。...
分类:编程语言   时间:2014-05-25 09:53:27    阅读次数:233
C++内存分配new
new表达式在内存生存周期内创建并初始化对象(两阶段:1、调用operator new创建内存,2、调用构造函数构造对象)也就是说,动态创建的对象其生命周期可能超出其创建的作用域。new的语法为:    ::(optional) new (placement_params)(optional) (type) initializer(optional) // 1) ::(opti...
分类:编程语言   时间:2014-05-24 20:47:44    阅读次数:427
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!