Just declare the getters to be const
:
class Document
{
public:
std::string getName() const;
int getLenght() const;
};
and specify their return values.
The error messages are not very readable, but in gcc:
error: passing A as B argument of C discards qualifiers
is almost always caused by trying to modify something that is const
.
The other messages are clear however:
error: no match for 'operator<<'
(operand types are 'std::ostream {aka std::basic_ostream}' and 'void')
cout << it->getName() << endl;
that is you are trying to pass a std::ostream and void to an operator.