没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
This assignment will give you practice building some simple classes and making use of basic C++ features including: encapsulation, references, dynamic memory allocation, simple constructors and destructors and consts. The program fragments provided have not been compiled or debugged. It is part of your task to spot bugs and make reasonable corrections, or ask for clarification in class. Generally when we give you skeleton code for classes it is intended. You are always free to add additional variables or methods to a class if you need them. This assignment is broken into three parts to suggest what to work on first.
资源推荐
资源详情
资源评论
Assignment One
This assignment will give you practice building some simple classes and
making use of basic C++ features including: encapsulation, references,
dynamic memory allocation, simple constructors and destructors and
consts.
The program fragments provided have not been compiled or debugged. It is
part of your task to spot bugs and make reasonable corrections, or ask for
clarification in class.
Generally when we give you skeleton code for classes it is intended. You are
always free to add additional variables or methods to a class if you need
them. This assignment is broken into three parts to suggest what to work on
first.
1. Design Requirements
Part 1) Building simple classes
R1.1) Create a class Person that models persons which follows the code
structure below.
R1.2) Persons should haveproperties: name, email_address, birthdate as
indicated in the class description below.
R1.3) Build a class Date as required below.
R1.4) Each class should have a printOn method called from an << operator.
This method should provide a text representation of the class for printing to
cout or other streams.
These are very simple C++ classes in that their variables are not objects but
are only intrinsic (non-object) types that are part of C++. Also these
variables are either values or pointers (they are not references yet).
//file Date.h
class Date
{
public:
Date();
Date( int year, int month, int day );
...
private:
int _year;
int _month;
int _day;
};
//end file Date.h
//file Person.h
class Person
{
public:
Person(void);
Person(char * their_name, char * email, int day, int month, int year);
char * GetName();
char * GetEmailAddress();
Date GetBirthDate();
void Print();
private:
char* name;
char* email_address;
Date date;
}; //end file Person.h
Part 2) Building a container class
Set container.
R2.1) Construct a class PersonSet which models a set, and which can only
hold Person objects.
R2.2) The sets should store the address of the person so that the original
object can be retrieved (not a copy).
R2.3) The storage for sets should be constructed from dynamic arrays
(created with new) which hold Person pointers, but sets should not be
bounded, they should grow as necessary as elements are added or removed.
R2.4) The elements are not stored in any particular order.
剩余7页未读,继续阅读
资源评论
u010955388
- 粉丝: 0
- 资源: 1
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功