Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //A.h
- // TODO: add guards
- class B; // we need this forward declaration, but just this one
- class A {
- private:
- B* bMmbr;
- public:
- A() {}
- void AMthd(){
- std::cout<<"AMthd()"<<std::endl;
- }
- void Qwe() {
- bMmbr->BMthd();
- }
- };
- //B.h
- // TODO: add guards
- class B {
- private:
- A* aMmbr;
- public:
- B() {}
- void BMthd() {
- std::cout<<"BMthd()"<<std::endl;
- }
- void Qwe() {
- aMmbr->AMthd();
- }
- };
- //Program.h
- class Program {
- public:
- Program() {}
- void main() {
- A a;
- a.Qwe();
- }
- };
- // main.cpp
- #include <iostream>
- struct Prog {
- #include "A.h"
- #include "B.h"
- #include "Program.h"
- static Program p;
- };
- Prog::Program Prog::p;
- void main() {
- Prog::p.main();
- }
Advertisement
Add Comment
Please, Sign In to add comment