Guest User

Untitled

a guest
May 27th, 2018
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.64 KB | None | 0 0
  1. class Foo;
  2.  
  3. class Bar{
  4. private:
  5. int x_;
  6. Foo foo_; // error: incomplete type
  7.  
  8. public:
  9. void setx(int x) {x_ = x;};
  10. void increment(int);
  11.  
  12. };
  13.  
  14.  
  15. class Foo{
  16.  
  17. public:
  18. void run(int y,Bar& bar) {bar.setx(y);};
  19. };
  20.  
  21. void Bar::increment(int i){foo_.run(i,*this);}
  22.  
  23. class Bar;
  24.  
  25. class Foo{
  26. public:
  27. void run(int y,Bar& bar);
  28. };
  29.  
  30. class Bar { ... };
  31.  
  32. void Foo::run(int y, Bar& bar) {
  33. bar.setx(y);
  34. }
  35.  
  36. class Foo;
  37.  
  38. class Bar{
  39. Foo foo_; // error: incomplete type
  40. };
  41.  
  42. class Foo{
  43. // put details here
  44. };
  45.  
  46. class Bar{
  47. Foo foo_; // OK
  48. };
  49.  
  50. class Foo;
  51.  
  52. class Bar{
  53. std::unique_ptr<Foo> foo_; // OK
  54. };
Add Comment
Please, Sign In to add comment