码迷,mamicode.com
首页 >  
搜索关键字:operator-    ( 3564个结果
HDU1542_Atlantis(扫描线/线段树+离散)
解题报告 题目传送门 题意: 求矩形并面积。 思路: 离散+线段树+扫描线。 #include #include #include #include using namespace std; struct Seg { int v; double h,lx,rx; friend bool operator < (Seg a,Seg b) { ...
分类:其他好文   时间:2014-08-12 00:49:03    阅读次数:260
条款十七: 在operator=中检查给自己赋值的情况
在赋值运算符中要特别注意可能出现别名的情况,其理由基于两点。其中之一是效率。如果可以在赋值运算符函数体的首部检测到是给自己赋值,就可以立即返回,从而可以节省大量的工作,否则必须去实现整个赋值操作。另一个更重要的原因是保证正确性。一个赋值运算符必须首先释放掉一个对象的资源(去掉旧值),然后根据新值分配...
分类:其他好文   时间:2014-08-11 14:56:22    阅读次数:212
条款十六: 在operator=中对所有数据成员赋值
当涉及到继承时,派生类的赋值运算符也必须处理它的基类成员的赋值!看看下面:class base {public: base(int initialvalue = 0): x(initialvalue) {}private: int x;};class derived: public base {.....
分类:其他好文   时间:2014-08-11 14:55:22    阅读次数:250
【转】c++ new操作符的重载
基本概念: 1. 操作符重载:C++支持对某个操作符赋予不同的语义 2. new操作符:申请内存,调用构造函数关于c++ new操作符的重载你知道c++的new操作符和operator new的区别么?也许你还会问,他们有区别吗?当你写下面这样的代码时,string *pa = new stri.....
分类:编程语言   时间:2014-08-11 14:21:02    阅读次数:221
zoj 2724
#include #include #include #include #include using namespace std;struct node{ char msg[20]; int a,b;};struct cmp{ bool operator()(const node ...
分类:其他好文   时间:2014-08-10 21:17:20    阅读次数:214
UVA 465-- Overflow (atof 函数)
Overflow  Write a program that reads an expression consisting of two non-negative integer and an operator. Determine if either integer or the result of the expression is too large to be rep...
分类:其他好文   时间:2014-08-09 21:35:29    阅读次数:321
条款十一: 为需要动态分配内存的类声明一个拷贝构造函数和一个拷贝赋值运算符
看下面一个表示string对象的类:// 一个很简单的string类class string {public: string(const char *value); ~string(); ... // 没有拷贝构造函数和operator=pr...
分类:其他好文   时间:2014-08-09 18:14:08    阅读次数:186
[leetcode]Divide Two Integers
Divide Two IntegersDivide two integers without using multiplication, division and mod operator.不用* 、/、%来做除法。只能加减了啊亲!算法思路:一个一个加上去必超时,例如dividend = Integ...
分类:其他好文   时间:2014-08-08 20:59:36    阅读次数:186
优先队列的使用方法
模版代码:#include#include#includeusing namespace std;struct node{ friend bool operator qi; for(i = 0; i , greater >qi2; for(i = 0; i qn; node...
分类:其他好文   时间:2014-08-08 17:54:56    阅读次数:246
STL中各容器之函数总结
一.序列和关联非共有函数 所有标准库共有函数  (构造,相关属性,迭代器,插入与删除,比较,swap) 其中operator>,operator>=,operator均不适用于priority_queue 顺序容器和关联容器共有函数 (1)   序列容器都提供5种相同的构造方法;关联容器都提供3种相同的构造方法 (2)    还有insert插入函数(序列容器有3个相同版本的插入。关联容...
分类:其他好文   时间:2014-08-07 13:15:30    阅读次数:189
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!