Advertisement
Guest User

Untitled

a guest
Oct 18th, 2017
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.52 KB | None | 0 0
  1.  
  2. #include <iostream>
  3.  
  4. class MyClass1 {
  5. int i;
  6. public:
  7. MyClass1(int ii) : i(ii) {}
  8. void printMe() { std::cout << i << "\n"; }
  9. };
  10.  
  11. /* ROSSZ:
  12. class Stuff0 {
  13. MyClass1 thing(42);
  14. public:
  15.  
  16. };
  17. */
  18.  
  19. /* JÓ#1 */
  20. class Stuff1 {
  21. MyClass1 thing;
  22. public:
  23. Stuff1() : thing(42) {}
  24. void printMe() { thing.printMe(); }
  25. };
  26.  
  27. /* JÓ#2 */
  28. class Stuff2 {
  29. MyClass1 thing{42};
  30. public:
  31. void printMe() { thing.printMe(); }
  32. };
  33.  
  34. int main() {
  35. Stuff1 s1;
  36. Stuff2 s2;
  37.  
  38. s1.printMe();
  39. s2.printMe();
  40.  
  41. return 0;
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement