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
1+1/2!+1/3!+...+1/n!
write a program that prompt the user to enter his height and weight,then calculate the body mass index and show the algorithm used
how to take time as input in the format (12:02:13) from user so that controls remains between these columns?
How to Split Strings with Regex in Managed C++ Applications?
write a program that reads a series of strings and prints only those strings begging with letter "b"
what mean void creat_object?in public class in this code class A{ public: int x; A(){ cout << endl<< "Constructor A";} ~A(){ cout << endl<< "Destructor A, x is\t"<< x;} }; void create_object(); void main() { A a; a.x=10; { A c; c.x=20; } create_object(); } void create_object() { A b; b.x=30; }
how to write a program that opens a file and display in reverse order?
write a program to calculate the amount of investment after a period n years if the principal investors was p and interest is calculated using compound interest,formular=a=p(1+r)^n
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)
How to swap two ASCII numbers?
how to diplay a external image of output on winxp by using c & c++,
write a program to perform generic sort in arrays?
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
create a stucture student containing field for roll no,class,year and marks.create 10 student annd store them in a file
Code for Method of Handling Factorials of Any Size?