fork download
  1. #include <iostream>
  2.  
  3. class A
  4. {
  5. friend class B;
  6. protected:
  7. A();
  8. A(std::string title, int xpos, int ypos);
  9. };
  10.  
  11. A::A()
  12. {
  13. //Do something
  14. }
  15. A::A(std::string title, int xpos, int ypos)
  16. {
  17. //Do something
  18. }
  19.  
  20. class B : A
  21. {
  22. protected:
  23. //Is that correct?
  24. A* m_pA;
  25. //Why not just A* m_pA;?
  26. public:
  27. B(std::string title, int xpos, int ypos);
  28. };
  29.  
  30. B::B(std::string title, int xpos, int ypos)
  31. {
  32. m_pA = new A(title, xpos, ypos);
  33. }
  34.  
  35. int main() {
  36.  
  37. return 0;
  38. }
Success #stdin #stdout 0s 3336KB
stdin
Standard input is empty
stdout
Standard output is empty