1、运算符重载 operator+ (take '+' for example) (1) 重载后必须至少有一个用户定义的操作数(struct class etc...),防止把一个C++标准的‘-’重载成'+' (2) 不能违反运算符原来的句法规则; 例如不能将'%'重载成一个操作数 (3)...
分类:
其他好文 时间:
2014-11-24 06:25:34
阅读次数:
127
短期代码阅读主要基于SGI的STL,测试环境则是GCC_4.8.3_STL和VS_STL。暂时不去配置BOOST等库STL细节。待续
1、istream_iterator 输入流迭代器
1)没有operator=操作,因为只读,不可写,所以编译不支持。迭代器句柄保存当前已读取到的数据。
_GLIBCXX_CONSTEXPR istream_iterator()
: _M...
分类:
其他好文 时间:
2014-11-23 20:16:58
阅读次数:
287
转自:http://blog.csdn.net/hackbuteer1/article/details/6595881分别使用C++中的运算符重载的方法来实现大数之间的数学运算,包括加法、减法、乘法、除法、n次方、取模、大小比较、赋值以及输入流、输出流的重载。。 并且使用这个大数模板,顺利AC了HD...
分类:
其他好文 时间:
2014-11-23 11:39:01
阅读次数:
245
The spread operator (...) allows you to "explode" an array into its individual elements.Spreate an array:console.log([1,2,3]); // [1, 2, 3] conso...
分类:
其他好文 时间:
2014-11-23 01:55:10
阅读次数:
228
一:起因
(0)拿出自己年初实现的queue队列,第一次用c++类实现queue,在和如今实现的其他复杂的STL对比,心情无比复杂;
注释:看到听到当年自己的所写所想,正的是一种享受 —— 倾听自己的幼稚也是一种美。
(1)闲话少说了,我自己现在回答自己的 三 (5) 中提到的问题,函数的返回值是用bool型还是void型??其实函数返回值是bool 还是 void是...
分类:
编程语言 时间:
2014-11-22 21:39:22
阅读次数:
316
operator=为什么值得注意?从语法上讲,下面的程序可以编译通过,我在另一篇笔记示例里面也这样用了。class A1{public: int operator=(int a)//参数是int,语法通过但逻辑不通。 { return 8; } int oper...
分类:
编程语言 时间:
2014-11-21 17:58:58
阅读次数:
183
题目大意:给出一个序列,问一段序列中,出现两次以上的颜色有多少种。
思路:和HH的项链很像。
CODE:
#include
#include
#include
#include
#define MAX 1000010
using namespace std;
struct Ask{
int x,y,_id;
bool operator <(con...
分类:
编程语言 时间:
2014-11-21 16:18:17
阅读次数:
279
stl::map是个很危险的容器,因为当用[]访问map元素时不是只读,还伴随着写操作:当访问的key值不存在时会自动插入。以下引自:http://www.cplusplus.com/reference/map/map/operator[]/Ifkmatches the key of an elem...
分类:
其他好文 时间:
2014-11-21 12:32:47
阅读次数:
139
Let $A$ be a nilpotent operator. Show how to obtain, from aJordan basis for $A$, aJordan basis of $\wedge^2A$.
分类:
其他好文 时间:
2014-11-21 10:37:06
阅读次数:
160
Divide two integers without using multiplication, division and mod operator.代码:class Solution {private: int res;public: int solve(long long divi...
分类:
其他好文 时间:
2014-11-20 11:45:17
阅读次数:
146