注册 登录
编程论坛 C++教室

求解一题C++ OOP题目 急!!

neil86918 发布于 2010-04-10 22:56, 589 次点击
各位大虾好 小弟刚开始接触OOP 想请问一道题目, 如下

用以下数据写一个名为Room的类程序
Room
name : string
num : int)

Room(void)
Room(int, string)
int getNum():int
void setNum(int)
getRoomDetails():string

(a) Write the class specification for Room.

(b) Implement the constructors and method you have specified in (a).
Additional information:
The default values for num and name in Room constructor are 0 and “Default Room Name” respectively.
The method getRoomDetails concatenates the values in num and name and return it as a string.

(c) Write a test program to test the constructor and methods in Room class. Create two instances of Room using the following data,
First Instance:
Use the default values
Second Instance:
num = 12
name = “JungleBytes Room”

最终运行程序时显示如下内容:

Room Number for default values:0
Room Number with given values:12
Room Details for room with default values:0, Default Room Name
Room Details for room with given values:12, JungleBytes Room
3 回复
#2
cnfarer2010-04-11 07:18
并不复杂啊,自己为什么不写!
#3
pangding2010-04-11 10:20
是个基础题。楼主就自己研究一下吧~
#4
neil869182010-04-14 21:40
1