Mail Archives: djgpp/1998/06/15/03:45:44
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 |
| |
\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\|/////////////////////////////////
- Raw text -