fork(1) download
  1. #include<iostream>
  2.  
  3.  
  4. class date{
  5. private:
  6. int A;
  7. int B;
  8. int C;
  9.  
  10. public:
  11. date(int,int);
  12.  
  13. bool setA(int a){
  14. A = a;
  15. return true;
  16. };
  17.  
  18. int getC(){
  19. return C;
  20. }
  21.  
  22. };
  23. date(int a,int b):A(a),B(b),C(A+B);
  24.  
  25.  
  26. int main(){
  27. date* hoge = new date(1,2);
  28.  
  29. hoge->setA = 5;
  30.  
  31. std::cout << hoge->getC() ;
  32. // なんで3なの!!!!!!!!!!!!
  33.  
  34. return 0;
  35.  
  36. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp:23:6: error: expected unqualified-id before ‘int’
 date(int a,int b):A(a),B(b),C(A+B);
      ^~~
prog.cpp:23:6: error: expected ‘)’ before ‘int’
prog.cpp: In function ‘int main()’:
prog.cpp:29:8: error: invalid use of member function ‘bool date::setA(int)’ (did you forget the ‘()’ ?)
  hoge->setA = 5;
  ~~~~~~^~~~
stdout
Standard output is empty