深拷贝实现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
顺序表可看成一位数组。#include<iostream>usingnamespacestd;typedefintDataType;#defineMAX_CAPACITY3classSeqlist{ friendostream&operator<<(ostream&os,Seqlist&x);public: Seqlist(DataTypecapacity=MAX_CAPACITY)//构造顺序表 :_size(0) ,_pd..
分类:
编程语言 时间:
2016-03-17 07:18:19
阅读次数:
249
//结构体的定义
structNode
{
Node(constDataType&d)
:_next(NULL)
,_prev(NULL)
,_data(d)
{}
public:
DataType_data;
Node*_prev;
Node*_next;
};
//双向链表类的定义
classDouList
{
friendostream&operator<<(ostream&os,DouList&l);
pu..
分类:
编程语言 时间:
2016-03-17 02:12:45
阅读次数:
356
typedefintDataType;#defineDEFAULT_CAPACITY7#defineDEFAULT_INC9#include<iostream>#include<assert.h>usingnamespacestd;classSeqlist{friendostream&operator<<(ostream&os,constSeqlist&s);public: //构造函数 Seqlist(intcapacity=DEFAULT..
分类:
编程语言 时间:
2016-03-12 14:53:34
阅读次数:
195
//3.3.2016 tangyeye#include<stdio.h>#include<iostream>#include<time.h>#include<fstream>#include<ostream>#include<string>using namespace std;#define MA
分类:
其他好文 时间:
2016-03-12 11:48:55
阅读次数:
154
【任务要求】1.实现:日期+天数=日期;2.实现:日期-天数=日期;3.实现:日期-日期=天数;【代码实现】#include<iostream>
usingnamespacestd;
classDate
{
friendostream&operator<<(ostream&os,constDate&d);//友元
public:
Date(intyear=1900,in..
分类:
其他好文 时间:
2016-03-02 20:13:28
阅读次数:
230
【问题描述】定义一个复数类,并重载运算符,以实现复数的加减乘除,相等与否,并显示其结果。【代码实现】//code.c
#include<iostream>
usingnamespacestd;
classComoplex
{
friendostream&operator<<(ostream&os,constComoplex&c);//友元
public:
..
分类:
其他好文 时间:
2016-02-29 02:07:52
阅读次数:
280
回顾
适配器
1、三种类型的适配器:
(1)容器适配器:用来扩展7种基本容器,利用基本容器扩展形成了栈、队列和优先级队列
(2)迭代器适配器:(反向迭代器、插入迭代器、IO流迭代器)
(3)函数适配器:函数适配器能够将仿函数和另一个仿函数(或某个值、或某个一般函数)结合起来。
【1】针对成员函数的函数适配器
【2】针对一般函数的函数适配器
...
分类:
编程语言 时间:
2016-02-19 14:28:46
阅读次数:
239
1、数据输出到文件(ofstream开启一个可供输出的文件) C++文件操作包括输入、输出、拷贝、批处理。 ofstream:写操作(输出)的文件类(由ostream引申而来) ifstream:读操作(输入)的文件类(由istream引申而来) fstream:可同时读写操作的文件类(由iostr
分类:
编程语言 时间:
2016-02-19 00:18:19
阅读次数:
294
#include <iostream> using namespace std; class Point{ public: Point(int _x = 0, int _y = 0, int _z = 0):x(_x), y(_y), z(_z){} Point(){} ~Point(){} fri
分类:
编程语言 时间:
2016-01-30 17:49:34
阅读次数:
189