Mail Archives: djgpp/2003/04/24/07:46:56
Well, since you have chosen to answer my question anyway, I feel I have to
respond.
I *have* tried it with the DJGPP compiler and it doesn't tell me anything.
It compiles and links just fine but then fails to work properly. What I am
interested in is why this is the case. Do you know why? My text book
certainly doesn't tell me (C++ Complete Reference 4th edition, Herbert
Schildt).
I know all about default arguments and deliberately avoid them as it
increases the risk of inadvertently missing out a parameter when using a
method. In any case the example I gave was simply there to illustrate the
point, and not an example of real code. I would of thought that was obvious.
Ellingworth, Richard <Richard DOT Ellingworth AT uk DOT perrymail DOT com> wrote:
> Hello. Sorry if this is a bit off-topic, but I have a C++ related
question.
> Is it OK to call constructors directly? For example, can you do this? :
Why ask here? You could just try it out, and see what the compiler
tells you. You'ld have the answer in a lot less time.
Anyway: this is an issue about the C++ programming language, not about
DJGPP, so you had better ask such questions elsewhere. Over in
comp.lang.c++, to name only the most obvious choice.
> class MyClass {
> public:
> MyClass( void )
> {
> MyClass( 0 );
> }
For a case like this, it's not even necessary to do it. If you search
a little in your C++ textbook, you'll learn about default arguments
values, which you can use to avoid even *having* the no-argument
constructor in this case. Go figure.
--
Hans-Bernhard Broeker (broeker AT physik DOT rwth-aachen DOT de)
Even if all the snow were burnt, ashes would remain.
- Raw text -