JKop wrote:[color=blue]
>
> Anyone know a way of calling a constructor?[/color]
There are two books suitable for you: "Accelerated C++" by Andrew
Koenig, Barbara Moo and "The C++ Programming Language" 3rd Edition or
Special Edition by Bjarne Stroustrup.
Keep in mind however that C++ is multiparadigm (it supports 4 paradigms)
and its size is essentially one of four languages (and then some because
most other languages do not fully support their paradigms).
[color=blue]
> At first, I was going to post the following code and ask if it was fully
> portable and all, but then it wouldn't compile.
>
>
> #include <cstdlib>
>
>
> class AnyClass {};
>
>
> int main()
> {
> AnyClass& blah = *static_cast<AnyClass*>
> ( std::malloc( sizeof(AnyClass) ) );[/color]
Don't use malloc() in C++. malloc() does not call the constructors of
the objects. Use new instead.
[color=blue]
>
> blah.AnyClass();
>
>
> //Work with it as normal
>
>
> blah.~AnyClass();
>
>
> std::free(&blah);
>
> }
>
>
> G++ gives the stupid reply:
>
>
> mem.cpp: In function `int main()':
> mem.cpp:14: calling type `AnyClass' like a method[/color]
The constructor is not aimed to be called after the construction
(definition) of an object.
[color=blue]
> Does anyone know of a compiler that gives meaningful explanations for errors
> and warnings? It doesn't necessarily have to produce anything, just
> "analyzes" the code and gives the errors and warnings, along with a helpful
> explanation.[/color]
Ehehe, it should have told you "You can't do that in Horizontal mode!". :-)
Regards,
Ioannis Vranos
http://www23.brinkster.com/noicys