fork download
  1. #include <iostream>
  2.  
  3. struct Somestruct {
  4. int a, b;
  5. };
  6.  
  7. class Someclass {
  8. private:
  9. int Integer;
  10. Somestruct Mystruct;
  11.  
  12. public:
  13.  
  14. Someclass(int i):
  15. Integer(i){}
  16.  
  17. void func(){
  18. Mystruct.a = Integer/2;
  19. Mystruct.b = Integer*2;
  20. };
  21.  
  22. const Somestruct& get() { return Mystruct; }
  23. };
  24.  
  25.  
  26. int main()
  27. {
  28. Someclass A(10);
  29. A.func();
  30. std::cout << A.get().a << " " << A.get().b << std::endl;
  31. }
Success #stdin #stdout 0s 4388KB
stdin
Standard input is empty
stdout
5 20