基本概念: 1. 操作符重载:C++支持对某个操作符赋予不同的语义 2. new操作符:申请内存,调用构造函数关于c++ new操作符的重载你知道c++的new操作符和operator new的区别么?也许你还会问,他们有区别吗?当你写下面这样的代码时,string *pa = new stri.....
分类:
编程语言 时间:
2014-08-11 14:21:02
阅读次数:
221
#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
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
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
一.序列和关联非共有函数
所有标准库共有函数 (构造,相关属性,迭代器,插入与删除,比较,swap)
其中operator>,operator>=,operator均不适用于priority_queue
顺序容器和关联容器共有函数
(1) 序列容器都提供5种相同的构造方法;关联容器都提供3种相同的构造方法
(2) 还有insert插入函数(序列容器有3个相同版本的插入。关联容...
分类:
其他好文 时间:
2014-08-07 13:15:30
阅读次数:
189
Effictive c++中将要让operator =()返回*this的引用,原因说是为了连环赋值,测试一下,发现不是如此,参考http://blog.csdn.net/nodeathphoenix/article/details/38146421class Test {public: Te...
分类:
其他好文 时间:
2014-08-07 12:15:49
阅读次数:
173
重载运算符,可以定义运算符为自己想要的效果,简化程序,以重载
#ifndef BOX_H
#define BOX_H
class Box{
public:
Box(double aLength=1.0,double aWidth=1.0,double aHeight=1.0);
double volume() const;
double getLength() const;
...
分类:
编程语言 时间:
2014-08-06 19:19:12
阅读次数:
233
今天是第二部分:玩家和AI
玩家主要是实现悔棋的功能
AI主要是搜索、最大最小算法,枝剪算法
1、每一步落子的步骤,为了可以悔棋
typedef struct ReversiStep
{
ReversiBitBoard m_LastMap;
ReversiStep& operator= (const ReversiStep& temp)
{
...