There are many questions with this title around StackOverflow with this title but none helped me and I don't really understand what's going on.
I am trying to make a class that generates a random word. First I am trying to put all vowels and consonants in two different static vector
s; however when testing the class I get this error:
cannot bind 'std::ostream {aka std::basic_ostream<char>}' lvalue to 'std::basic_ostream<char>&&'
I don't really understand this error. ostream
rvalue? I have never seen this and I can't think of any situation where that would make sense.
This is my class so far:
class RandomWordGenerator {
public:
RandomWordGenerator() {
vowels.push_back(Letter('A'));
}
static Word generate() {
std::cout << vowels.front() << std::endl; // the error pops here
Word w(std::string("test"));
return w;
}
private:
static std::vector<Letter> vowels;
static std::vector<Letter> consonants;
};
std::ostream& operator <<(std::ostream& os, Letter& l) {
return os << l.inner(); // a std::string
}
Why is this happening? How can I solve it?