Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

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

1+1/2!+1/3!+...+1/n!

2402


write a program that prompt the user to enter his height and weight,then calculate the body mass index and show the algorithm used

4846


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

2261


How to Split Strings with Regex in Managed C++ Applications?

3649


write a program that reads a series of strings and prints only those strings begging with letter "b"

3106


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; }

2574


how to write a program that opens a file and display in reverse order?

3054


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

2849


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)

3406


How to swap two ASCII numbers?

3029


how to diplay a external image of output on winxp by using c & c++,

3436


write a program to perform generic sort in arrays?

3061


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

2451


create a stucture student containing field for roll no,class,year and marks.create 10 student annd store them in a file

2703


Code for Method of Handling Factorials of Any Size?

2474