From: Endlisnis Newsgroups: comp.os.msdos.djgpp Subject: Re: Pointer dec call the constructor? Date: Sat, 24 Apr 1999 14:27:11 -0300 Organization: BrunNet Lines: 36 Message-ID: <3721FEEF.E928EB2F@unb.ca> References: <7fr7hv$ouc$1 AT nntp1 DOT atl DOT mindspring DOT net> NNTP-Posting-Host: ftnts1c38.brunnet.net Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Mailer: Mozilla 4.04 [en] (Win95; U) To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Reply-To: djgpp AT delorie DOT com 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