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 4 of 5.

Suchita said:   1 decade ago
What is the difference between Containment and Composition?

Rupali Kate said:   1 decade ago
Inheritance and composition are two different concepts:

Inheritance deals with classes and the composition deals with objects.

Composition means deriving a complex object from a simpler object.

Rahul said:   1 decade ago
Containment and composition are same.

Karthik said:   1 decade ago
Inheritance is the answer. Its the class inside another existing class.

Answer C is wrong.

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

ABHI said:   1 decade ago
This answer should be abstraction.

Lovish said:   9 years ago
In inheritance, we can use data members and member function the class which is inherited but in composition you can initialise the object of other class and with the help of that object you can access its members.

For example:

class a
{
public:
int x;
}

class b:public a
{
x=10;
}

// But in composition,

class a
{
public:
int x;
}

class b
{
a obj;
obj.x=10;
}

We can't access x directly in other class.

We have to create obj of that class but in inheritance we can do.

Sachin kunte said:   9 years ago
Composition means containment. Where one object may contain attributes of other object.

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).

Gelu Menumorut said:   9 years ago
The question is very inaccurate, it should have been:.

"Of the defining object of one class as a member of another class?".

Compare this with "Of using object of one class inside another class?".

Actually "using" means to have access to an instance by any mean (even as a parameter) and call it's member functions. None of the options match this trivial functionality, but "None" was provided as an option.


Post your comments here:

Your comments will be displayed after verification.