虚继承(个人感觉用到的地方不多,项目中没有用到这个的)最典型的例子就是iostream的继承方式class istream : virtual public ios{...};//此处就是虚继承,指定ios为虚基类class ostream : virtual public ios{...};cla...
分类:
编程语言 时间:
2014-10-06 21:41:10
阅读次数:
134
Each type of iostream has a concept of where its “next” character will come from (if it’s an istream) or go (if it’s an ostream). In some situations y...
分类:
移动开发 时间:
2014-09-24 15:17:16
阅读次数:
226
#include
using namespace std;
class Point{
public:
Point(int _x = 0, int _y = 0, int _z = 0):x(_x), y(_y), z(_z){}
Point(){}
~Point(){}
friend ostream& operator<<(ostream &os, const Point &pd);
...
分类:
编程语言 时间:
2014-09-19 04:29:05
阅读次数:
183
mystring.h
#ifndef _MYSTRING_H_
#define _MYSTRING_H_
#include
#include
class mystring
{
friend std::ostream &operator<...
分类:
其他好文 时间:
2014-09-06 09:49:13
阅读次数:
214
16.53 编写你自己版本的print函数,并打印一个、两个及五个实参来测试它,要打印的每个实参都应有不同的类型。#include#includeusing namespace std;template ostream& print(ostream &os,const T &t){ osost...
分类:
其他好文 时间:
2014-09-02 00:03:23
阅读次数:
206
16.21 编写你自己的DebugDelete版本。#include#includeusing namespace std;class DebugDelete{public: DebugDelete(ostream &s=cerr):os(s) {} template void ...
分类:
其他好文 时间:
2014-09-01 12:13:13
阅读次数:
216
一些基本的模版特性:非类参数模版模版所声明的参数可以不是类参数,可以声明的非类参数包括整数(double,float不可以),enum,对象引用或指针。通过模版嵌套实现类或非类参数载类方法参数上的重载(调用时实现,不在定义时实现)友元函数模版:直接举例:template friend ostream...
分类:
其他好文 时间:
2014-08-26 13:34:36
阅读次数:
279
小记:运行环境:win xp vs2008#include #include using std::cout;using std::cin;using std::endl;using std::istream;using std::ostream;class y{private: int a;pub...
分类:
编程语言 时间:
2014-08-25 11:23:24
阅读次数:
253
#include #include #include int main(){ using namespace std; int casts[10]={6,7,2,9,4,11,8,7,10,5}; vector dice(10); copy(casts,casts+10,di...
分类:
其他好文 时间:
2014-08-15 20:57:09
阅读次数:
195