I think you should distinguish between “these analyzes”, “compilation”, “these links” and “this works”, and try to think like a C ++ parser or compiler / linker to see that first example
Example e1();
Looks like a function declaration. The parser will understand this in this way, so you cannot call, for example. member function on e1 . The compiler will generate a symbol related to some function (it still does not see it), but since the function is not used anywhere, it will not complain. If you add this code, it will be:
e1.f();// since e1 is a function, it has no member 'f' => compiler error
(as a side element: this code will also compile:
int a_function_prototype(int);
but after the compiler finishes, the linker will start looking for the actual function bodies and will not find it.
Now since the line
Example* e = new Example();
contains the keyword new , which the compiler recognizes, and he knows that it can only be found in the distribution + construction of a new object, it will generate code for this.
xtofl source share