Guest User

Untitled

a guest
Oct 21st, 2014
275
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.80 KB | None | 0 0
  1. //A.h
  2. // TODO: add guards
  3. class B; // we need this forward declaration, but just this one
  4. class A {
  5. private:
  6.     B* bMmbr;
  7. public:
  8.     A() {}
  9.    
  10.     void AMthd(){
  11.         std::cout<<"AMthd()"<<std::endl;
  12.     }
  13.  
  14.     void Qwe() {
  15.         bMmbr->BMthd();
  16.     }
  17. };
  18.  
  19. //B.h
  20. // TODO: add guards
  21. class B {
  22. private:
  23.     A* aMmbr;
  24. public:
  25.     B() {}
  26.     void BMthd() {
  27.         std::cout<<"BMthd()"<<std::endl;
  28.     }
  29.  
  30.     void Qwe() {
  31.         aMmbr->AMthd();
  32.     }
  33. };
  34.  
  35. //Program.h
  36. class Program {
  37. public:
  38.     Program() {}
  39.  
  40.     void main() {
  41.         A a;
  42.         a.Qwe();
  43.     }
  44. };
  45.  
  46. // main.cpp
  47. #include <iostream>
  48.  
  49. struct Prog {
  50. #include "A.h"
  51. #include "B.h"
  52. #include "Program.h"
  53.  
  54.     static Program p;
  55. };
  56.  
  57. Prog::Program Prog::p;
  58.  
  59. void main() {
  60.     Prog::p.main();
  61. }
Advertisement
Add Comment
Please, Sign In to add comment