#include<iostream>
using namespace std;
class NoDef {
public:
NoDef();
};
int main(int argc, char** argv)
{
NoDef nd1(); // Line 1
NoDef nd2; // Line 2
return 0;
};
So line #1 has no problems in compiling but line #2 gives a linker error. I understand the linker error. There is no definition to link to. But why line 1 is not giving any errors? What difference does the parentheses make?
Using VS2013.
Thank you.
NoDef nd1();
declares a function named nd1
returning Nodef
object, no error
NoDef nd2;
tries to use the constructor which isn't defined , hence linker unhappy