fork download
  1. #include<iostream>
  2.  
  3. class date{
  4. private:
  5. int A;
  6. int B;
  7. int C = A+B;
  8.  
  9. public:
  10. date(int,int);
  11.  
  12. bool setA(int a){
  13. this->A = a;
  14. return true;
  15. }
  16.  
  17. int getC(){
  18. return this->C;
  19. }
  20.  
  21. };
  22. date::date(int a,int b):A(a),B(b),C(a+b){}
  23.  
  24.  
  25. int main(){
  26. date* hoge = new date(1,2);
  27.  
  28. hoge->setA(5);
  29.  
  30. std::cout << hoge->getC() ;
  31. // なんで3なの!!!!!!!!!!!!
  32.  
  33. return 0;
  34. }
Success #stdin #stdout 0s 15232KB
stdin
Standard input is empty
stdout
3