fork download
  1.  
  2.  
  3. #include <iostream>
  4.  
  5. using namespace std;
  6.  
  7. enum FACE { NORTH, SOUTH, EAST, WEST };
  8.  
  9. struct Direction {
  10. FACE face;
  11. };
  12.  
  13. std::ostream& operator<<(std::ostream& os, Direction const& dir)
  14. {
  15. return os << dir.face;
  16. }
  17.  
  18. int main(){
  19. Direction dir;
  20. dir.face = EAST;
  21. cout << dir; // I want this to print EAST instead of having to do dir.face
  22. }
Success #stdin #stdout 0s 3140KB
stdin
Standard input is empty
stdout
2