C++ Programming - OOPS Concepts - Discussion

Discussion Forum : OOPS Concepts - General Questions (Q.No. 13)
13.
Which of the following concepts provides facility of using object of one class inside another class?
Encapsulation
Abstraction
Composition
Inheritance
Answer: Option
Explanation:
No answer description is available. Let's discuss.
Discussion:
48 comments Page 2 of 5.

Abhinav said:   1 decade ago
But this is what the whole concept of Object Oriented Programming. But Question said a feature of OOPS is Composition, I have learned only four of them, and composition is not one of them.

Vinesh said:   1 decade ago
Inheritance is having properties (member variables and member functions) of a class into another class and Composition is having object of some class into another class.

Sparsh Gupta said:   5 years ago
Inheritance will acquire one class properties, but here the question is not about the class, it's about an object inside a class, so the answer is composition.
(6)

Phaneendhra said:   1 decade ago
Inheritance will acquire one class properties, but here the question is not about the class, it's about an object inside a class, so the answer is composition.

Shubha said:   1 decade ago
Inheritance means deriving features of base class to sub-class.. where as composition means deriving a complex object from a simpler object..

Royal said:   1 decade ago
In the name "COMPOSITION" itself indicating that nature of ingredients.

So, here ingredients are objects & nature is is class.

Akshay said:   9 years ago
The car has an engine is a composition here we are talking about some part of the car.

The car is a 4wheeler is an inheritance.
(1)

AMOL said:   9 years ago
Inheritance can be know by IS A relationship.

Composition is known by HAS A relationship (its basically a code reuse).

Arjun said:   1 decade ago
Composition is has a type relationship car has wheels.

class wheel
{
int id;
};
class car
{
wheel w[4];
};

Sneha bele said:   1 decade ago
Can anyone give clear explanation of difference between Inheritance and Composition with examples of both?


Post your comments here:

Your comments will be displayed after verification.