When I do this:

// header file:

#include <list>

using namespace std;

class myClass {

list<int> myMethod();
};

// cpp file:

list<int> myClass::myMethod() {


}

In the cpp file, 'myMethod' is underlined in red and when I hover over it, it says:

"std::list<int, std::allocator<int>> myClass::myMethod()

Error: declaration is incompatible with "<error-type> myClass::myMethod()""

But when I make it as a standalone function, outside a class, with no pre-declaration, there is no problem.

What's going on?

Thanks in advance.