J
JKop
Anyone know a way of calling a constructor?
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) ) );
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
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.
-JKop
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) ) );
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
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.
-JKop