Questions 1 -7 uses the following declaration: class Room { private: int room_no
ID: 3545734 • Letter: Q
Question
Questions 1 -7 uses the following declaration:
class Room
{
private:
int room_no; //line a
int capacity;
public:
Room();
Room(int room_no_v, int capacity_v);
static int getJanitorNo(int room_no);
int setCapacity(int cap) {capacity = cap;}
int getRoomNo() {return room_no;}
int getCapacity() {return capacity;}
};
//Implementation
Room::Room()
{
room_no = 0;
capacity = 0;
}
Room::Room(int room_no, int capacity)
{
this->room_no = room_no; //line Room1
this->capacity = capacity; //line Room2
}
int Room::getJanitorNo(int room_no)
{
if (room_no < 100) //line getJanitorNo 1
return 1;
else
return 2;
}
int main()
{
int var = 0; //line 1
Room room1, room2(10,50); //line 2
Room room3(102,75); //line 3
Room room4(1); //line 4
var = room1.room_no; //line 5
var = Room::getJanitorNo(room1.getRoomNo()); //line 6
Explanation / Answer
1. b. 2
2. a. Program compiles and runs and var is assigned to 0
3. a. Yes
4. c. static
5. c. Both a and b are true
6. d. private
7. d. Constructor
8. d. Static
9. e. None of these
10. c. Static
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.