From: "Alexander von L\"unen" Newsgroups: comp.os.msdos.djgpp Subject: Re: constructor/destructor Date: Mon, 15 Jun 1998 08:41:39 +0200 Organization: University of Bonn, Inst. f. CS Lines: 41 Message-ID: <3584C223.41C6@informatik.uni-bonn.de> References: <897871443 DOT 1942 DOT 0 DOT nnrp-01 DOT 9e989aee AT news DOT demon DOT co DOT uk> NNTP-Posting-Host: birke.informatik.uni-bonn.de Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Precedence: bulk Dan Goodman wrote: > > a few months ago I wrote a program that included something like this: > > vector v; > ... > v.vector(); > > where vector is a class with a constructor that sets the x,y coords to 0, > the program worked then, but now (possibly with a newer version of djgpp) it > gives me errors (wont compile). Is using a constructor function in this way > not legal? Is there any other way of using this function or should I just > make a copy of the function with another name (seems like a bit dodgy that > to me)? > > Thanks in advance, > Dan I never tried this. But, your approach is rather tautologic. I mean, since you apparently defined a default constructor (vector()), there is no need to call it seperatly. It is called as soon as you create an instance of class vector. So a well-behaved compiler should complain about it. It might even be prohibited in the C++ standard. Creating a member function that does what you want to do, mustn't be a bad idea, since you can call it anywhere (in the constructor and from anywhere else). Greets, Alex -- ////////////////////////////////|\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ / \ | "Who quotes a lot exhibits memory rather than intelligence!" | | (Leonardo da Vinci) | | | | Alexander von L"unen | | | | E-Mail: luenen AT informatik DOT uni-bonn DOT de | | | | WWW: http://titan.cs.uni-bonn.de/~luenen/index.html | | | \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\|/////////////////////////////////