error: invalid use of member (did you forget the ‘&’ ?)

This is a wiki page. Be bold and improve it!

If you have any questions about the content on this page, don't hesitate to open a new ticket and we'll do our best to assist you.

Error:

error: invalid use of member (did you forget the ‘&’ ?)

This can be due to missing parentheses.
For example:

std::string path = "file.txt";
std::ifstream dir(path.c_str, std::ifstream::in); // Missing ().

Here the string object calls a function but the () are missing.
The code should be:

std::string path = "file.txt";
std::ifstream dir(path.c_str(), std::ifstream::in);