If I have a class named Object, what's the difference between creating an instance just like that:
#include <stdio.h>
Object var;
main ()
{
var.test();
}
or
#include <stdio.h>
main ()
{
Object* var = new Object();
var->test();
}
Which is the differente between a global object (which you can use wherever you want) and create a dynamic object in the main.cpp? In theory it should be the same, right? The both method can be used in any file.cpp.
<stdio.h>? That's a C header that should not appear in C++.)new): you shouldn't use them if you don't have to :)void func() {var->test();}beforemain()and you'll find it won't compile. You're mixing the concepts of scope and object lifetime - they are very different things, even if they sometimes go together.