码迷,mamicode.com
首页 >  
搜索关键字:c++ operator 运算符重载    ( 4162个结果
记录以下boost::shared_ptr的一个使用细节
shared_ptr::operator->返回的是T*类型指针,非const T*指针。因此通过const shared_ptr&类型的ptr可以直接调用T各个原始的方法,不用担心const与非const问题。具体shared_ptr::operator->实现如下,摘自boost1.52.0版本...
分类:其他好文   时间:2014-07-09 23:34:42    阅读次数:194
c++ string assign =
C++ string类的成员函数,用于拷贝、赋值操作,它们允许我们顺次地把一个string 对象的部分内容拷贝到另一个string 对象上。string &operator=(const string &s);把字符串s赋给当前字符串string &assign(const char *s);用c类...
分类:编程语言   时间:2014-07-09 23:22:50    阅读次数:287
c++第九章-(运算符重载)
一些规则1.c++不允许用户自己定义新的运算符,只能对已有的c++运算符进行重载。2.除了五个运算符不允许重载外,其他运算符允许重载:.成员访问运算符*成员指针访问运算符::与运算符sizeof尺寸运算符?:条件运算符3.重载运算符必须和用户定义的自定义类型的对象一起使用。(也就是说,参数不能全部都...
分类:编程语言   时间:2014-07-09 13:56:27    阅读次数:286
整形提升(c语言基础)
When you use an arithmetic operator, the operands go through two conversions.Integer promotions: If int can represent all values of the type, then the...
分类:编程语言   时间:2014-07-09 13:46:00    阅读次数:278
初探C++ 深拷贝与浅拷贝
赋值运算符'='重载...
分类:编程语言   时间:2014-07-08 16:42:40    阅读次数:187
C++运算符重载为友元函数学习笔记
初探C++运算符重载学习笔记  在上述的博客中...
分类:编程语言   时间:2014-07-08 13:14:27    阅读次数:168
C++:模板友元
模板友元函数在类内声明类外定义时都必须加模板前缀,另外模板要写在一个文件内// generates undefined error for the operator#include #include template class array { int size;public: array(); t...
分类:编程语言   时间:2014-07-06 19:56:39    阅读次数:199
effective c++ 条款10 handle assignment to self operator =
非强制性,但是个好习惯当使用连锁赋值时很有用x=y=z=10;class Window{ public: Window& operator=(int size) { ... return *this; }}这个规则适用于 -,+, +=,-= etc
分类:编程语言   时间:2014-07-06 16:14:49    阅读次数:264
Divide Two Integers
Divide two integers without using multiplication, division and mod operator.思路:不能使用乘法除法以及取模运算来计算两个数相除。主要做法就是,将因子不断乘2(向左移位即可实现),同时结果从1不断移位加倍,等到除数大于被除数一...
分类:其他好文   时间:2014-07-06 15:34:24    阅读次数:197
Leetcode Divide Two Integers
Divide two integers without using multiplication, division and mod operator.不用乘、除、求余操作,返回两整数相除的结果,结果也是整数。假设除数是2,相除的商就是被除数二进制表示向右移动一位。假设被除数是a,除数是b,因为不知...
分类:其他好文   时间:2014-07-05 20:37:18    阅读次数:193
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!