I doubt that only one of the objects is being created. Let's modify your code in the following way:
static int objId = 0;
class MyClass
{
public:
MyClass() { cout << "Create object "<< objId << endl; }
};
void main()
{
objId = 2;
MyClass obj2();
objId = 1;
MyClass obj1; }
Now you can distinguish whether the first or the second call or both are being executed.
[AMENDED]
Apparently the C++ compiler interprets the first one (obj2) as a function prototype declaraction. It thinks you are declaring a function with name obj2 that takes no parameters and returns a value of type MyClass.
When I compile it with VC++ the compiler generates the warning:
prototyped function not called (was a variable definition intended?)
which indicates what's going on. If you would create an object via new, this syntax would be allowed, i.e:
MyClass* pObj2 = new MyClass();
Hope that helped clarify it.