can we declare an object of a class in another class?(assume
both class as public classes)

Answer Posted / poonam

yes,we can declare the object of one class into another class. The kind of relationship is called Containership or nesting. this is one of the best feature of c++ which allow inheritence and reusability.
for eg:
class alpha {.....};
class beta {....};
class gamma
{
alpha a;
beta b;
...
};


Creation of one object into another is very different from that of an independent object. Independent object is created
by cnstructors when declared with the arguments.


for further details refer c++ by balguruswamy page no.240

Is This Answer Correct ?    13 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

3. Program to find the Sum of give series. a. (1)+(1+2)+(1+2+3)+(1+2+3+4)+……………………………….. b. 1/1+1/9+1/25+1/49+……………...

4570


write a program that can LOCATE and INSERT elements in array using c++ programming languages.

3679


write a program to perform generic sort in arrays?

2799


can you please write a program for deadlock that can detect deadlock and to prevent deadlock.

2925


Teta-Omeg-Big-Oh Show that f(n) = n2 + 3n3 is ;(n3).

3369






write a function that reverse the elements of an array in place.The function must accept only one pointer value and return void.

4232


Write a C/C++ program that connects to a MySQL server and displays the global TIMEZONE.

4762


Performance Algorithm A performs 10n2 basic operations and algorithm B performs 300 lg n basic operations. For what value of n does algorithm B start to show its better performance?

7600


Write a C/C++ program that connects to a MySQL server and checks if the InnoDB plug-in is installed on it. If so, your program should print the total number of disk writes by MySQL.

2263


develop a program to calculate and print body mass index for 200 employees

2406


Code for Small C++ Class to Transform Any Static Control into a Hyperlink Control?

2765


find level of following tree (state, parent) " J,D I,D H,C E,B F,B G,C B,A D,A C,A A,& K,E L,E L,F M,F N,G O,H P,I P,H Q,I R,J S,K U,P T,L

2212


solve the problem in the programming language C++"if a five digit number is input through the keyboard.Write a program to calculate the sum of its digits(hint: use the modulus operator)

3146


how to take time as input in the format (12:02:13) from user so that controls remains between these columns?

2042


write a program to convert temperature from fa height into celcius and vise versa,use modular programming

2675