fork(15) download
  1. #include <iostream>
  2.  
  3. class CFoo {
  4. public :
  5. CFoo(void);
  6. CFoo(int num);
  7. virtual ~CFoo();
  8. virtual void SetValue(int num);
  9. virtual int GetValue(void);
  10. virtual void Dump(void) const;
  11. private:
  12. int m_num;
  13. };
  14.  
  15. CFoo::CFoo(void) : m_num(0) { }
  16. CFoo::CFoo(int num) : m_num(num) { }
  17. CFoo::~CFoo() { }
  18. void CFoo::SetValue(int num) { m_num = num; }
  19. int CFoo::GetValue(void) { return(m_num); }
  20. void CFoo::Dump(void) const { printf("%d\n",m_num);}
  21.  
  22. int main() {
  23. CFoo* foo = new CFoo();
  24. foo->SetValue(10);
  25. int n = foo->GetValue();
  26. std::cout << "n = " << n << std::endl;
  27. delete foo;
  28. return 0;
  29. }
Success #stdin #stdout 0.01s 2856KB
stdin
Standard input is empty
stdout
n = 10