fork download
  1. #include <iostream>
  2. #include <string>
  3.  
  4. class address {
  5. public:
  6.  
  7. address() : addr_("Some Address"), pobox_(200) {}
  8.  
  9. const std::string& addr() const { return addr_; }
  10. void addr(std::string value) { addr_ = value; }
  11.  
  12. int pobox() const { return pobox_; }
  13. void pobox(int value ) { pobox_ = value; }
  14.  
  15. private:
  16. std::string addr_;
  17. int pobox_;
  18. };
  19.  
  20. class person {
  21. address a_;
  22. public:
  23. void Test() {
  24. std::cout << "Address: " << a_.addr() << std::endl;
  25. std::cout << "PO Box : " << a_.pobox() << std::endl;
  26. }
  27. };
  28.  
  29. int main() {
  30. person p;
  31. p.Test();
  32. return 0;
  33. }
Success #stdin #stdout 0s 3428KB
stdin
Standard input is empty
stdout
Address: Some Address
PO Box : 200