1

Is there any difference in these codes:

std::string dirName = argv[1];
MyRecordDatabaseType myDB(Selector<std::string>((std::string)dirName));

and

std::string dirName = argv[1];
MyRecordDatabaseType myDB(Selector<std::string>(dirName));

I have no idea why the second version doesn't compile.

The compiler tells me:

error: request for member ‘createGroupWriter’ in ‘myDB’, which is of non-class type ‘main(int, char**)::MyRecordDatabaseType(Selector<std::basic_string<char, std::char_traits<char>, std::allocator<char> > >)’

at line:

MyRecordDatabaseType::writer_type myWriter(myDB.createGroupWriter(groupName));

And sorry, but I can't show you the code of Selector or any other class.

Maybe you can help me without that?

Bo Persson
  • 90,663
  • 31
  • 146
  • 203
Adi
  • 2,011
  • 2
  • 15
  • 14

1 Answers1

7

Yes, the difference is that this line

MyRecordDatabaseType myDB(Selector<std::string>(dirName)); 

can also be written like

MyRecordDatabaseType myDB(Selector<std::string>  dirName); 

and is a declaration of a function myDB that returns MyRecordDatabaseType.

See C++ most vexing parse

Community
  • 1
  • 1
Bo Persson
  • 90,663
  • 31
  • 146
  • 203