fork(1) download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. struct InputNum {
  5. private:
  6. const int input;
  7.  
  8. public:
  9. InputNum(const int num) : input(num){};
  10.  
  11. int get() const
  12. {
  13. return input;
  14. }
  15. bool greater_than(const int target) const
  16. {
  17. return input > target;
  18. }
  19. bool less_than(const int target) const
  20. {
  21. return input < target;
  22. }
  23. bool equals(const int target)
  24. {
  25. return input == target;
  26. }
  27. };
  28.  
  29. void func(const InputNum &num)
  30. {
  31. num.equals(1);
  32. num.less_than(1);
  33. }
  34.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp: In function ‘void func(const InputNum&)’:
prog.cpp:31:15: error: passing ‘const InputNum’ as ‘this’ argument discards qualifiers [-fpermissive]
   num.equals(1);
               ^
prog.cpp:23:8: note:   in call to ‘bool InputNum::equals(int)’
   bool equals(const int target)
        ^~~~~~
stdout
Standard output is empty