fork 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 a, int b) {
  12. A = a;
  13. B = b;
  14. C = a + b;
  15. }
  16.  
  17. bool setA(int a){
  18. A = a;
  19. C = a + B;
  20. return true;
  21. };
  22.  
  23. int getC(){
  24. return C;
  25. }
  26.  
  27. };
  28.  
  29.  
  30. int main(){
  31. Date* hoge = new Date(1,2);
  32.  
  33. hoge->setA(5);
  34.  
  35. std::cout << hoge->getC() ;
  36. // なんで3なの!!!!!!!!!!!!
  37.  
  38. return 0;
  39.  
  40. }
Success #stdin #stdout 0s 15232KB
stdin
Standard input is empty
stdout
7