Re: Problem with constructors
From: Peter MacMillan (peter_at_writeopen.com)
Date: 03/30/05
- Next message: vivekiyer_at_gmail.com: "Re: How to encript header files."
- Previous message: darkstorm: "Problem with constructors"
- In reply to: darkstorm: "Problem with constructors"
- Next in thread: manuthomas23_at_hotmail.com: "Re: Problem with constructors"
- Reply: manuthomas23_at_hotmail.com: "Re: Problem with constructors"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Wed, 30 Mar 2005 02:24:02 -0500
darkstorm wrote:
> class A
> {
> public:
> void Fun();
> private:
> Vector2D vec;--------(A)
> };
This is just a definition of the class. When you instantiate the class
(eg. dynamically: A* a = ew A(); statically: A a;) it will create vec
and call it's constructor as part of the class initialization.
>
> void A::Fun()
> {
> Vector2D vec1;-------(B)
> .
> .
> .
> }
When your execution gets into that function, a Vector2D named vec1 is
created (and destroied at the end of the function).
>
> Here at (B) constructor for Vector2D is getting called, but at (A)
> constructor is not getting called. What can be the reason?
>
> Thanks
B is part of some code, A is part of a definition of a class.
-- Peter MacMillan e-mail/msn: peter@writeopen.com icq: 1-874-927 GCS/IT/L d-(-)>-pu s():(-) a- C+++(++++)>$ UL>$ P++ L+ E-(-) W++(+++)>$ N o w++>$ O !M- V PS PE Y+ t++ 5 X R* tv- b++(+) DI D+(++)>$ G e++ h r-- y(--)
- Next message: vivekiyer_at_gmail.com: "Re: How to encript header files."
- Previous message: darkstorm: "Problem with constructors"
- In reply to: darkstorm: "Problem with constructors"
- Next in thread: manuthomas23_at_hotmail.com: "Re: Problem with constructors"
- Reply: manuthomas23_at_hotmail.com: "Re: Problem with constructors"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|