为什么这段代码无法编译?
这些代码有什么区别吗:
std::string dirName = argv[1];
MyRecordDatabaseType myDB(Selector<std::string>((std::string)dirName));
我
std::string dirName = argv[1];
MyRecordDatabaseType myDB(Selector<std::string>(dirName));
不知道为什么第二个版本不能编译。
编译器告诉我:
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));
抱歉,我无法向您展示 Selector 或任何其他类的代码。
也许你可以帮助我,不需要那个?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
是的,不同之处在于这一行
也可以写成
和 ,它是返回
MyRecordDatabaseType
的函数myDB
的声明。请参阅 C++ 最令人烦恼的解析
Yes, the difference is that this line
can also be written like
and is a declaration of a function
myDB
that returnsMyRecordDatabaseType
.See C++ most vexing parse