100% satisfaction guarantee Immediately available after payment Both online and in PDF No strings attached
logo-home
c++ inheritance Exams 2024 $7.99   Add to cart

Exam (elaborations)

c++ inheritance Exams 2024

 2 views  0 purchase
  • Course
  • Institution

c++ inheritance Exams 2024

Preview 1 out of 3  pages

  • June 4, 2024
  • 3
  • 2023/2024
  • Exam (elaborations)
  • Questions & answers
avatar-seller
c++ inheritance Exams 2024
define a copy constructor or assignment operator for a class that contains a pointer to
ABC - ANS-USE A virtual constructor

EXAMPLE non-virtual function of the base class to call a virtual function? - ANS-void
Shape::print() const
float a = this->area(); // area() is pure virtual

Explain use of Private Inheritance
The use of public inheritance implies an is-a relationship between a base class and its
descendant. Unlike public inheritance, private inheritance is used when you want to
inherit the implementation of the base class without the is-a commitment. -
ANS-aggregation(CAN)and containment(CAN-NOT)?

Aggregated object can exist without container. Composited object is managed by it's
container and cannot live without it. Interviewer would probably expect that you will say
that composition implemented by creating object by value and aggregation implemented
by creating object by reference (or pointer)
Private inheritance models the "is implemented in terms of a" relationship, rather than
the is-a relationship that is modeled by public inheritance.
Private inheritance results in all public functions of a class being inherited as private
functions
Private inheritance should be used sparingly, but can be necessary when you need to
override a virtual function

Explain use of Private Inheritance - ANS-prevent class inheriting
1.make the class's constructors private and to use the Named Constructor Idiom
2.virtual inheritance.

How do I separate interface from implementation in C++ - ANS-An abstract base class.

how to define a "virtual constructor"? - ANS-effect of a virtual constructor by a virtual
clone() member function (for copy constructing), or a virtual create() member function
(for the default constructor).
virtual Shape* clone() const = 0; // The Virtual (Copy) Constructor

How to implement Named Constructor - ANS-declare all the class's constructors in the
private or protected sections, and you provide public static methods that return an

The benefits of buying summaries with Stuvia:

Guaranteed quality through customer reviews

Guaranteed quality through customer reviews

Stuvia customers have reviewed more than 700,000 summaries. This how you know that you are buying the best documents.

Quick and easy check-out

Quick and easy check-out

You can quickly pay through credit card or Stuvia-credit for the summaries. There is no membership needed.

Focus on what matters

Focus on what matters

Your fellow students write the study notes themselves, which is why the documents are always reliable and up-to-date. This ensures you quickly get to the core!

Frequently asked questions

What do I get when I buy this document?

You get a PDF, available immediately after your purchase. The purchased document is accessible anytime, anywhere and indefinitely through your profile.

Satisfaction guarantee: how does it work?

Our satisfaction guarantee ensures that you always find a study document that suits you well. You fill out a form, and our customer service team takes care of the rest.

Who am I buying these notes from?

Stuvia is a marketplace, so you are not buying this document from us, but from seller modockochieng06. Stuvia facilitates payment to the seller.

Will I be stuck with a subscription?

No, you only buy these notes for $7.99. You're not tied to anything after your purchase.

Can Stuvia be trusted?

4.6 stars on Google & Trustpilot (+1000 reviews)

75057 documents were sold in the last 30 days

Founded in 2010, the go-to place to buy study notes for 14 years now

Start selling
$7.99
  • (0)
  Add to cart