码迷,mamicode.com
首页 >  
搜索关键字:operator-    ( 3564个结果)
C++ 中string类的三种模拟实现方式
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
C++ 写类中的一个bug修复
#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
智能指针(模拟实现auto_ptr,shared_ptr,scooeptr 以及定制删除器c++ 实现)
#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
C# 重载运算符
如果你想让自己定义的类型可以用运算符进行运算,那么可以通过重载运算符来实现; 示例: 通过使用operator关键字定义静态成员函数来重载运算符。
分类:Windows程序   时间:2016-03-20 19:38:23    阅读次数:187
LeetCode Divide Two Integers
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
Win7 64位 VS2015环境编译cegui-0.8.5
首先是去官网下载源码与依赖库 http://cegui.org.uk/ 然后得提一下,编译DX11版本带Effects11框架的话会有问题,也就是默认情况编译有问题,这是因为VS2015升级后对operator new和delete做一更改。 具体看微软说明 https://msdn.microso
分类:Windows程序   时间:2016-03-20 14:32:45    阅读次数:1453
lintcode-medium-Divide Two Integers
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
c++ 实现Sring类
深拷贝实现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
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!