fork(1) download
  1. #include <iostream>
  2. using namespace std;
  3. class Int
  4. {
  5. int x;
  6. Int(int x)
  7. {
  8. this.x = x;
  9. }
  10. String toString(Int y)
  11. {
  12. return y.x.toString();
  13. }
  14. Int plus(Int y)
  15. {
  16. Int temp;
  17. temp.x = this.x + y.x;
  18. return temp;
  19. }
  20. Int minus(Int y)
  21. {
  22. Int temp;
  23. temp.x = this.x - y.x;
  24. return temp;
  25. }
  26. Int times(Int y)
  27. {
  28. Int temp;
  29. temp.x = this.x * y.x;
  30. return temp;
  31. }
  32. Int div(Int y)
  33. {
  34. Int temp;
  35. if(y.x!=0)
  36. {
  37. temp.x = this.x/y.x;
  38. return temp;
  39. }
  40. return null;
  41. }
  42. bool isPrime(Int y)
  43. {
  44. for(int i=2;i<=sqrt(y.x);i++)
  45. {
  46. if(y.x%i==0)return false;
  47. }
  48. return true;
  49. }
  50. int main() {
  51. // your code goes here
  52. return 0;
  53. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp:10:2: error: ‘String’ does not name a type
  String toString(Int y)
  ^
prog.cpp:53:1: error: expected ‘}’ at end of input
 }
 ^
prog.cpp: In constructor ‘Int::Int(int)’:
prog.cpp:8:8: error: request for member ‘x’ in ‘this’, which is of pointer type ‘Int* const’ (maybe you meant to use ‘->’ ?)
   this.x = x;
        ^
prog.cpp: In member function ‘Int Int::plus(Int)’:
prog.cpp:16:7: error: no matching function for call to ‘Int::Int()’
   Int temp;
       ^
prog.cpp:16:7: note: candidates are:
prog.cpp:6:2: note: Int::Int(int)
  Int(int x)
  ^
prog.cpp:6:2: note:   candidate expects 1 argument, 0 provided
prog.cpp:3:7: note: Int::Int(const Int&)
 class Int
       ^
prog.cpp:3:7: note:   candidate expects 1 argument, 0 provided
prog.cpp:17:17: error: request for member ‘x’ in ‘this’, which is of pointer type ‘Int* const’ (maybe you meant to use ‘->’ ?)
   temp.x = this.x + y.x;
                 ^
prog.cpp: In member function ‘Int Int::minus(Int)’:
prog.cpp:22:7: error: no matching function for call to ‘Int::Int()’
   Int temp;
       ^
prog.cpp:22:7: note: candidates are:
prog.cpp:6:2: note: Int::Int(int)
  Int(int x)
  ^
prog.cpp:6:2: note:   candidate expects 1 argument, 0 provided
prog.cpp:3:7: note: Int::Int(const Int&)
 class Int
       ^
prog.cpp:3:7: note:   candidate expects 1 argument, 0 provided
prog.cpp:23:17: error: request for member ‘x’ in ‘this’, which is of pointer type ‘Int* const’ (maybe you meant to use ‘->’ ?)
   temp.x = this.x - y.x;
                 ^
prog.cpp: In member function ‘Int Int::times(Int)’:
prog.cpp:28:7: error: no matching function for call to ‘Int::Int()’
   Int temp;
       ^
prog.cpp:28:7: note: candidates are:
prog.cpp:6:2: note: Int::Int(int)
  Int(int x)
  ^
prog.cpp:6:2: note:   candidate expects 1 argument, 0 provided
prog.cpp:3:7: note: Int::Int(const Int&)
 class Int
       ^
prog.cpp:3:7: note:   candidate expects 1 argument, 0 provided
prog.cpp:29:17: error: request for member ‘x’ in ‘this’, which is of pointer type ‘Int* const’ (maybe you meant to use ‘->’ ?)
   temp.x = this.x * y.x;
                 ^
prog.cpp: In member function ‘Int Int::div(Int)’:
prog.cpp:34:7: error: no matching function for call to ‘Int::Int()’
   Int temp;
       ^
prog.cpp:34:7: note: candidates are:
prog.cpp:6:2: note: Int::Int(int)
  Int(int x)
  ^
prog.cpp:6:2: note:   candidate expects 1 argument, 0 provided
prog.cpp:3:7: note: Int::Int(const Int&)
 class Int
       ^
prog.cpp:3:7: note:   candidate expects 1 argument, 0 provided
prog.cpp:37:18: error: request for member ‘x’ in ‘this’, which is of pointer type ‘Int* const’ (maybe you meant to use ‘->’ ?)
    temp.x = this.x/y.x;
                  ^
prog.cpp:40:10: error: ‘null’ was not declared in this scope
   return null;
          ^
prog.cpp: In member function ‘bool Int::isPrime(Int)’:
prog.cpp:44:26: error: ‘sqrt’ was not declared in this scope
   for(int i=2;i<=sqrt(y.x);i++)
                          ^
prog.cpp: At global scope:
prog.cpp:53:1: error: expected unqualified-id at end of input
 }
 ^
stdout
Standard output is empty