fork download
  1. enum Direction{Forward,Backward};
  2.  
  3. template<Direction dir = Forward>
  4. class X
  5. {
  6. private:
  7.  
  8. Direction my_direction_;
  9. public:
  10.  
  11. void set_direction(Direction dir)//here I'm getting an error
  12. {
  13. my_direction_ = this->dir;
  14. }
  15.  
  16. };
  17.  
  18. int main()
  19. {
  20. return 0;
  21. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp: In member function ‘void X<dir>::set_direction(Direction)’:
prog.cpp:11: error: declaration of ‘Direction dir’
prog.cpp:3: error:  shadows template parm ‘Direction dir’
stdout
Standard output is empty