So I have a problem....
I've a method
void MainWindow::loadItems(const ArticleStore& store)
{
}
that I try to call like this inside the MainWindow class
ArticleStore store();
loadItems(store)
And I get this error
mainwindow.cpp:15: error: no matching function for call to ‘MainWindow::loadItems(ArticleStore (&)())’
mainwindow.h:19: note: candidates are: void MainWindow::loadItems(const ArticleStore&)
ArticleStore definition:
class ArticleStore
{
public:
ArticleStore();
};
So the question is what went wrong?
views:
121answers:
2
+9
A:
It's because
ArticleStore store();
is interpreted by the compiler as a function declaration.
That's explain why compiler is looking for ‘MainWindow::loadItems(ArticleStore (&)())’
You must write instead:
Article store; // With no parenthesis
yves Baumes
2009-08-02 11:26:15
+1
A:
ArticleStore store; loadItems(store);
Notice the lack of brackets after the name. The compiler is mistaking your version as a function prototype for a function called store, taking no arguments and returning an ArticleStore
instance. Then you pass this function pointer to the next function which doesn't work.
KayEss
2009-08-02 11:27:57