码迷,mamicode.com
首页 >  
搜索关键字:rhs    ( 171个结果
关于 += 运算符
op=运算符op=运算符用在如下形式的语句中:lhsop=rhs;这条语句的意思:lhs=lhsop(rhs);例如:count+=5;这条语句和下面的语句效果一样:count=count+5;注意:如果rhs表达式结果的类型不同于lhs的类型,编译器会自动插入一个转换将rhs值转换成lhs的类型。
分类:其他好文   时间:2015-07-16 14:18:35    阅读次数:90
Effective C++ 条款24
若所有参数皆需类型转换,请为此采用non-member函数我们直奔主题 如果你定义一个有理数类如下class Rational{ public: Rational(int numerator=0, int denominator=1);//非explicit,允许隐式转换 const Rational operator*(const Rational& rhs); .....
分类:编程语言   时间:2015-06-27 18:23:35    阅读次数:126
Effective C++ 条款11
在operator=中处理“自我赋值”什么是自我赋值,很明显。就是自己的值赋值给了自己。下面的代码就是自我赋值:class Widget { public: Widget& operator=(const Widget& rhs) { delete p; p=new int(ths.p); return *this; }...
分类:编程语言   时间:2015-06-23 10:17:26    阅读次数:131
BZOJ 1572: [Usaco2009 Open]工作安排Job( 贪心 )
贪心...按截止时间排序 , 然后从小到大考虑 . 假设当前考虑第 i 个任务 , 若目前已选工作数 #include#include#include#include#define rep( i , n ) for( int i = 0 ; i rhs.t; } };data A[ maxn ...
分类:其他好文   时间:2015-06-06 19:20:21    阅读次数:412
hdu1785 You Are All Excellent
本着多谢思路的原则,还是把题解及代码记录下啦吧。 用到的atan2函数,atan2(y,x)应该就是与x轴的夹角弧度了,网太渣,没查。 #include #include #include using namespace std; struct point{ double x,y; bool operator < (const point&rhs) const { ...
分类:其他好文   时间:2015-05-23 11:32:04    阅读次数:123
Effective C++ 随笔(4)
条款21:必须返回对象时,别妄想返回其reference例子:Raional类可以执行有理数的一些运算,并且使用heap内存申请 并且其operator*函数为const Rational& operator*(const Rational& lhs,const Rational& rhs){ Ra...
分类:编程语言   时间:2015-05-09 23:19:10    阅读次数:208
读书笔记_Effective C++_构造,析构,赋值
条款五class Empty { }; 这样的一个类,当C++处理过后,编译器会为它声明一个copy构造函数、一个copy assignment操作符、一个析构函数和一个default构造函数,所有这些函数都是public且inline。class Empty { public: Empty() { ... } Empty(const Empty& rhs) { ... }...
分类:编程语言   时间:2015-04-28 11:57:50    阅读次数:156
go与c++链接示例
go lang与c/c++的链接示例:foo.hpp//foo.hpp#ifndef _FOO_HPP_#define _FOO_HPP_templateT add(const T& lhs,const T& rhs){ return lhs+rhs;}void display();#endif /...
分类:编程语言   时间:2015-04-11 19:11:21    阅读次数:180
C++ operator= 注意事项
下面先看一段代码: #include using namespace std; class Point{ public: Point(float x=0.0,float y=0.0):_x(x),_y(y){} Point& operator=(const Point& rhs); void printData(){ cout<<"_x="<<_x<<endl; cout<<"...
分类:编程语言   时间:2015-04-10 13:43:03    阅读次数:146
C++中用成员函数指针模拟多态
1.成员函数指针的用法 1 #include 2 using namespace std; 3 class base 4 { 5 public: 6 int test(int lhs,int rhs) 7 { 8 cout*baseFunction)(1,2);//相...
分类:编程语言   时间:2015-04-04 16:36:48    阅读次数:184
171条   上一页 1 ... 12 13 14 15 16 ... 18 下一页
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!