Question

Describe each of the following C++ features. Polymorphism: Inheritance: Composition: Encapsulation: Default parameters:

Describe each of the following C++ features.
     

     Polymorphism:

Inheritance:

Composition:

     Encapsulation:
     
     Default parameters:
0 0
Add a comment Improve this question Transcribed image text
Answer #1

Polymorphism in C++

The word polymorphism means having many forms. In simple words, we can define polymorphism as the ability of a message to be displayed in more than one form.

Real life example of polymorphism, a person at the same time can have different characteristic. Like a man at the same time is a father, a husband, an employee.

In C++ polymorphism is mainly divided into two types:

  • Compile time Polymorphism
    • Function Overloading
    • Operator Overloading
  • Runtime Polymorphism
    • Function Overriding

Inheritance in C++

The capability of a class to derive properties and characteristics from another class is called Inheritance. Inheritance is one of the most important feature of Object Oriented Programming.
Sub Class: The class that inherits properties from another class is called Sub class or Derived Class.
Super Class:The class whose properties are inherited by sub class is called Base Class or Super class.

Encapsulation in C++

Encapsulation is a process of combining data members and functions in a single unit called class. This is to prevent the access to the data directly, the access to them is provided through the functions of the class. It is one of the popular feature of Object Oriented Programming(OOPs) that helps in data hiding.

Object composition in C++

This process of building complex objects from simpler ones is called object composition.

In real-life, complex objects are often built from smaller, simpler objects.

For example, a car is built using a metal frame, an engine, some tires, a transmission, a steering wheel, and a large number of other parts.

A personal computer is built from a CPU, a motherboard, some memory, etc… Even you are built from smaller parts: you have a head, a body, some legs, arms, and so on.

Default Arguments in C++

A default argument is a value provided in a function declaration that is automatically assigned by the compiler if the caller of the function doesn’t provide a value for the argument with a default value.

Add a comment
Know the answer?
Add Answer to:
Describe each of the following C++ features. Polymorphism: Inheritance: Composition: Encapsulation: Default parameters:
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT