0
#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.

madu
  • 5,018
  • 12
  • 50
  • 88

1 Answers1

4
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

P0W
  • 44,365
  • 8
  • 69
  • 114