《设计模式与XML》实验报告.docVIP

  • 1
  • 0
  • 约2.26千字
  • 约 5页
  • 2026-02-26 发布于天津
  • 举报

《设计模式与XML》实验报告

实验序号:1

学号

姓名

专业、班

实验地点

指导教师

时间

一、实验目的及要求

1.自己设计学生类,再把该类改造成Singleton模式的类,并在main()中调试。

2.自己设计图书类,再把该类改造成ProtoType模式的类,并在main()中调试。

3.编程实现Adapter模式,并在main()中调试。

二、实验设备(环境)及要求

Windows,VC++6.0

三、实验内容与步骤

1. singleton模式c++代码:

#includeiostream.h

classStudent

{

protected:

Student(){};

private:

staticStudent*_instance;

public:

staticStudent*Instance();

charID[6];

charName[10];

intage;

charsex[2];

charstatus[10];

voidsetAge(intn)

{

age=n;

}

};

Student*Student::_instance=0;

Student*Student::Instance()

{

if(_instance==0)

{

_instance=newStudent;

}

retur

文档评论(0)

1亿VIP精品文档

相关文档