Object Oriented Programming BS (2nd) Midterm Exam Date: 03-05-2021 Submit Till 03-05-2021 (4:00 PM) Q1. Write a class definition that creates a class called leverage with one private data member,...


Object Oriented Programming<br>BS (2nd)<br>Midterm Exam<br>Date: 03-05-2021<br>Submit Till 03-05-2021 (4:00 PM)<br>Q1. Write a class definition that creates a class called leverage with one private data member, crowbar, of<br>type int and one public function whose declaration is void pry().<br>Q2. Write a class definition that creates a class called leverage with one private data member, crowbar, of<br>type int and one public function whose declaration is void pry(). Write a member function called<br>getcrow(). This function should return the value of the crowbar data. Assume the function is defined<br>within the class definition.<br>Q3. Write a constructor that initializes to 0 the crowbar data, a member of the leverage class. Assume that<br>the constructor is defined within the class definition.<br>Q4. Create a class called time that has separate int member data for hours, minutes, and seconds. One<br>constructor should initialize this data to 0, and another should initialize it to fixed values. Another<br>member function should display it, in 11:59:59 format. The final member function should add two<br>objects of type time passed as arguments. A main() program should create two initialized time objects<br>(should they be const?) and one that isn't initialized. Then it should add the two initialized values<br>together, leaving the result in the third time variable. Finally it should display the value of this third<br>variable. Make appropriate member functions const.<br>Assignment: Write code of all Examples and all Exercise questions of Chapter 6 then submit CPP files.<br>Marks will be given after viva of the assignment. (Submit Till 15-03-2021)<br>Email at: gaonlinexams@gmail.com<br>

Extracted text: Object Oriented Programming BS (2nd) Midterm Exam Date: 03-05-2021 Submit Till 03-05-2021 (4:00 PM) Q1. Write a class definition that creates a class called leverage with one private data member, crowbar, of type int and one public function whose declaration is void pry(). Q2. Write a class definition that creates a class called leverage with one private data member, crowbar, of type int and one public function whose declaration is void pry(). Write a member function called getcrow(). This function should return the value of the crowbar data. Assume the function is defined within the class definition. Q3. Write a constructor that initializes to 0 the crowbar data, a member of the leverage class. Assume that the constructor is defined within the class definition. Q4. Create a class called time that has separate int member data for hours, minutes, and seconds. One constructor should initialize this data to 0, and another should initialize it to fixed values. Another member function should display it, in 11:59:59 format. The final member function should add two objects of type time passed as arguments. A main() program should create two initialized time objects (should they be const?) and one that isn't initialized. Then it should add the two initialized values together, leaving the result in the third time variable. Finally it should display the value of this third variable. Make appropriate member functions const. Assignment: Write code of all Examples and all Exercise questions of Chapter 6 then submit CPP files. Marks will be given after viva of the assignment. (Submit Till 15-03-2021) Email at: [email protected]
Jun 07, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here