Advertisement
Ikmik

forward_declaration.cpp

May 9th, 2017
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.29 KB | None | 0 0
  1. class B;
  2.  
  3. template<class T>
  4. class A {
  5.     B* bp;
  6. public:
  7.     T x;
  8.     A(T _x) {x = _x; bp = new B(); }
  9.     T f() {
  10.         return bp->f();
  11.     }
  12. };
  13.  
  14. class B {
  15.     A<int>* ap;
  16. public:
  17.     int f() {
  18.         return 0;
  19.     }
  20. };
  21.  
  22. int main() {
  23.     A<int> a(0);
  24.     return a->f();
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement