fork download
  1. //////////// CEditBox.hpp header file
  2. #include <memory>
  3. #include <string>
  4.  
  5. class CLabel;
  6.  
  7.  
  8. class CEditBox
  9. {
  10. public:
  11. CEditBox(std::string);
  12. private:
  13. std::unique_ptr<CLabel> _label;
  14. };
  15.  
  16. //////////// CLabel.hpp header file
  17.  
  18. #include <string>
  19. //#include "CLabel.hpp"
  20.  
  21. class CLabel
  22. {
  23. public:
  24. CLabel(std::string name) : _name(std::move(name)) {}
  25. private:
  26. std::string _name;
  27. };
  28.  
  29. ///////////// CEditBox.cpp source file
  30.  
  31. //#include "CEditBox.hpp"
  32. //#include "CLabel.hpp"
  33.  
  34. CEditBox::CEditBox(std::string name)
  35. : _label(new CLabel(std::move(name)))
  36. {
  37. }
  38.  
  39. ///////////// main.cpp source file
  40.  
  41. //#include "CEditBox.hpp"
  42.  
  43. int main()
  44. {
  45. CEditBox box("Hello world"); // no need to 'know' CLabel here
  46. }
  47.  
Success #stdin #stdout 0s 3024KB
stdin
Standard input is empty
stdout
Standard output is empty