这个设计有点怪!
2011-12-18 22:26
204 查看
#include "stdafx.h"
#include <string>
#include <iostream>
using namespace std;
class Base
{
public:
Base();
virtual void DisPaly() = 0;
};
Base::Base()
{
}
class ManA : public Base
{
public:
ManA();
ManA(string name,string sex,int old);
virtual void DisPaly();
friend class Show;
private:
string name;
string sex;
int old;
};
ManA::ManA(string name,string sex,int old)
:name(name)
,sex(sex)
,old(old)
{
}
void ManA::DisPaly()
{
cout<<"ManA--name:"<<name<<endl;
cout<<"ManA--sex:"<<sex<<endl;
cout<<"ManA--old:"<<old<<endl;
}
class ManB : public Base
{
public:
ManB();
ManB(string name);
virtual void DisPaly();
friend class Show;
private:
string name;
};
ManB::ManB()
{
}
ManB::ManB(string name)
:name(name)
{
}
void ManB::DisPaly()
{
cout<<"ManB--name:"<<name<<endl;
}
class Show
{
public:
void DisPlay(Base &base);
};
void Show::DisPlay(Base &base)
{
base.DisPaly();
}
int _tmain(int argc, _TCHAR* argv[])
{
ManA man("lhy","man",26);
ManB B("lhy_class_B");
Show infoShow;
infoShow.DisPlay(man);
infoShow.DisPlay(B);
}
#include <string>
#include <iostream>
using namespace std;
class Base
{
public:
Base();
virtual void DisPaly() = 0;
};
Base::Base()
{
}
class ManA : public Base
{
public:
ManA();
ManA(string name,string sex,int old);
virtual void DisPaly();
friend class Show;
private:
string name;
string sex;
int old;
};
ManA::ManA(string name,string sex,int old)
:name(name)
,sex(sex)
,old(old)
{
}
void ManA::DisPaly()
{
cout<<"ManA--name:"<<name<<endl;
cout<<"ManA--sex:"<<sex<<endl;
cout<<"ManA--old:"<<old<<endl;
}
class ManB : public Base
{
public:
ManB();
ManB(string name);
virtual void DisPaly();
friend class Show;
private:
string name;
};
ManB::ManB()
{
}
ManB::ManB(string name)
:name(name)
{
}
void ManB::DisPaly()
{
cout<<"ManB--name:"<<name<<endl;
}
class Show
{
public:
void DisPlay(Base &base);
};
void Show::DisPlay(Base &base)
{
base.DisPaly();
}
int _tmain(int argc, _TCHAR* argv[])
{
ManA man("lhy","man",26);
ManB B("lhy_class_B");
Show infoShow;
infoShow.DisPlay(man);
infoShow.DisPlay(B);
}
相关文章推荐
- 设计原则:消除Switch...Case的过程,可能有点过度设计了。
- 这个看起来有点简单!--实验吧
- 看看这个网站的设计 你能打几分
- 整数数组中,每个元素均出现两次,除了一个元素例外,如何找出这个元素?能否设计一个线性时间的算法,且不需要额外的存储空间?
- PPT:大数据时代的设计特点——不了解这个你做不了今天的设计
- vs 2008 asp设计视图不能用的问题解决(肯定可行!这个问题搞的我好晕!)
- 在开发板S3C2440中如何用自带的QT去设计一个界面来实现控制摄像头,这个界面的框架图是怎样的
- 项目管理实战之团队管理 对团队的管理需要重视以下几个方面 一个系统不仅需要优秀的分析和设计,更需要一个良好的过程将其从蓝图转化为实现。这个过程中最重要的是对团队的管理,也就是人的管理
- tensorflow训练了10万次,运行完毕,对这个word2vec终于有点感觉了
- Windows Embedded Standard 7这个媒婆有点拽
- 简单工作流引擎是按一个单据的(类型),单据的(主键) 来处理流程步骤的,这个就是工作流设计的核心思想
- 任何国家都无法限制数字货币。为什么呢? 要想明白这个问题需要具备一点区块链的基础知识: 区块链使用的大致技术包括以下几种: a.点对点网络设计 b.加密技术应用 c.分布式算法的实现 d.数据存储技术 e.拜占庭算法 f.权益证明POW,POS,DPOS 原因一: 点对点网络设计 其中点对点的P2P网络是bittorent ,由于是点对点的网络,没有中心化,因此在全球分布式的网
- IOS8 设置TableView Separatorinset 分割线从边框顶端开始 (这个和我之前的有点区别)
- 虫洞语音助手:这个助手有点冷
- 如何你是一个教育产品设计者 你该如何设计这个产品?
- 031 二进制1的数量(keep it up, 看到这个问题,刚开始有点蒙)
- 移植gtk,这个配置有点早,可以了解一下他的工作流程
- tensorflow训练了10万次,运行完毕,对这个word2vec终于有点感觉了
- 多亏 Sketch,我这个小码农可以自己设计 app 了
- 【一个男人娶了四个妻子。临终时却。。。【这个故事有点深度。其实人人都是这样。。但现实中我们往往忽略真正意义上的东西】