I have the following code (it's actually longer, i'm just putting up the part that throws an error)
//Header class
enum class Color{
Rouge, Bleu, Vert
};
class Bike{
Color _color;
Bike (Color color): _color(color){
}
void print() const;
}
//Cpp file (assume all inclusions are done properly)
void Bike::print() const{
std::cout<<_color;
}
//Main
main(){
Color couleur (Color::Rouge);
Bike obj(couleur);
obj.print()
}
So everything else works perfectly until i print the color (std::cout<<_color;
). I'm i using enum
in the wrong way? why can't i print that color?
error code
[Error] initializing argument 1 of 'std::basic_ostream<_CharT, _Traits>& std::operator<<(std::basic_ostream<_CharT, _Traits>&&, const _Tp&) [with _CharT = char; _Traits = std::char_traits<char>; _Tp = Color]'