CS1004 C++ ObjectOrientedProgramming Midterm 2 v3 Moderated
CS1004 C++ ObjectOrientedProgramming Midterm 2 v3 Moderated
Karachi Campus
CLO #1: Discuss knowledge of underlying concepts of object-oriented paradigm like abstraction,
encapsulation, polymorphism, inheritance etc.
Q1: Write short answers (2-3 lines) for the following questions: [15 minutes, 10 marks(5*2)]
a. Do you agree with the statement: “When a function is declared a friend by a class, it becomes
a member of that class”? Justify your answer.
b. Can a constant member function be overloaded with a non-constant version?
c. Can the diamond problem be mitigated explicitly disambiguating member function calls in the
derived class?
d. What will be the order of constructors and destructors in a code snippet given below:
class A { };
class B { };
class C : public B, public A { };
class D : public C { };
main() { D d1; }
e. Is there any problem in a code snippet given below? If yes, how can we resolve it?
class A { public: int x;};
class B : private A { };
class C : public B { public: C() {x = 10; } };
main() { C c1;}
CLO #4: Design and assess small and medium scale C++ programs using OOP principles.
Q2: You are developing a software system to manage various security professionals and their roles
within a firm. The system has a class hierarchy to represent different roles and entities involved in
the industry. [20 minutes, 10 marks (4*2.5)]
a. Create an Employee class that has basic information about individuals employed such as their
name, employee ID, salary all of which are protected members. Create a parameterized
constructor to set these attributes.
b. Create an Analyst class that represents security analysts and inherits from the Employee
class. It has additional attributes “specialization” and “isCertified”. Create a parameterized
constructor to set the attributes. The specialization can only be “Network”, “Incident
CLO #4: Design and assess small and medium scale C++ programs using OOP principles.
Q3: You are required to develop a Software for a pastry shop located in UAE. The system should
assist in managing the pricing, taxes, and profits from pastry sales. Each pastry has a production
cost, and the price at which it is sold by the shop is subject to certain taxes and pricing regulations.
Additionally, there is a requirement to calculate the retail price for each pastry, considering a 6%
Goods and Services Tax (GST). [25 minutes, 10 marks (5*2)]