1.原始版本(拷贝构造和赋值运算符重载时,需要重新开辟空间)#include<iostream>
#include<string>
usingnamespacestd;
classString
{
friendostream&operator<<(ostream&os,constString&S);
public:
String(char*str="")
:_str(newchar[..
分类:
编程语言 时间:
2016-04-01 06:43:42
阅读次数:
494
#include"wz.h"
#include"sts.h"
class_string
{
friendstd::istream&operator>>(std::istream&is,_string&a);//bug12
friendstd::ostream&operator<<(std::ostream&os,_string&a);
public:
_string()//默认构造函数
{
length=0;
b=newch..
分类:
编程语言 时间:
2016-03-31 07:12:57
阅读次数:
260
一、运算符重载 定义格式: operator 运算符 (); 说明: 1. 运算符重载是通过创建运算符函数operator()来实现的; 2. 函数operator()可以是它将要操作的类的成员,也可以不是类的成员,但非成员operator()函数通常是类的友元函数; 3. 一般来讲,运算符重载的功 ...
分类:
其他好文 时间:
2016-03-29 12:39:05
阅读次数:
156
//顺序表
#include<iostream>
usingnamespacestd;
template<typenameT>
classSeqList
{
public:
SeqList();
~SeqList();
SeqList(constSeqList&s);
SeqList&operator=(constSeqList&s);
void_CheakCapacity();
voidPushBack(constT&x);
voi..
分类:
其他好文 时间:
2016-03-28 00:31:46
阅读次数:
191
#define_CRT_SECURE_NO_WARNINGS
#include<iostream>
usingnamespacestd;
template<classT>
classAuto_ptr
{
public:
Auto_ptr(T*_x):x(_x)
{}
Auto_ptr(Auto_ptr<T>&s):x(s.x)
{
s.x=NULL;
}
Auto_ptr&operator=(Auto_ptr<T>&s)
{
x=s...
分类:
编程语言 时间:
2016-03-26 08:49:48
阅读次数:
263
如果你想让自己定义的类型可以用运算符进行运算,那么可以通过重载运算符来实现; 示例: 通过使用operator关键字定义静态成员函数来重载运算符。
Divide two integers without using multiplication, division and mod operator. If it is overflow, return MAX_INT. 举个例子比较容易理解,74 / 5, 这里 5*2=10 < 10*2=20
分类:
其他好文 时间:
2016-03-20 15:58:49
阅读次数:
184
首先是去官网下载源码与依赖库 http://cegui.org.uk/ 然后得提一下,编译DX11版本带Effects11框架的话会有问题,也就是默认情况编译有问题,这是因为VS2015升级后对operator new和delete做一更改。 具体看微软说明 https://msdn.microso
分类:
Windows程序 时间:
2016-03-20 14:32:45
阅读次数:
1453
Divide two integers without using multiplication, division and mod operator. If it is overflow, return 2147483647 Given dividend = 100 and divisor = 9
分类:
其他好文 时间:
2016-03-20 14:27:14
阅读次数:
173
深拷贝实现string类#define_CRT_SECURE_NO_WARNING1
#include<iostream>
#include<string>
usingnamespacestd;
classString
{
public:
friendostream&operator<<(ostream&os,String&str);
friendStringoperator+(constString&str1,constStri..
分类:
编程语言 时间:
2016-03-20 02:25:53
阅读次数:
692