Mail Archives: djgpp/1999/04/24/22:00:30
Lark wrote:
> Does a pointer declaration call the constructor of the type of object it
> points to? For example:
>
> class A{
> public:
> A(){x=5}
> int x;};
> A * ob;
> is A::A() called on ob? And if not, if I had a second class,
No, there is not an object yet to call the contructor on.
> class B:public A{
> public:
> B(){y=7}
> int y;};
>
> and then write this:
> A * ob;
> ob = new B();
> is A::A() called first or is B::B() called first? Sorry if this isn't
> terribly clear, and thanks for any help!
A::A() is called first.
--
(\/) Endlisnis (\/)
s257m AT unb DOT ca
Endlisnis AT BrunNet DOT Net
Endlisnis AT HotMail DOT com
ICQ: 32959047
- Raw text -