Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. problem in linking tow relative classes

problem in linking tow relative classes

Scheduled Pinned Locked Moved C / C++ / MFC
questionc++help
3 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    Reza Azizi
    wrote on last edited by
    #1

    i have 2 class a and b like this: //heder file a #include "b.h" class a { b objb; } //heder file b #include "a.h" class b { a obja; } vc++ can not complie these codes please tell me how can i do that?

    R M 2 Replies Last reply
    0
    • R Reza Azizi

      i have 2 class a and b like this: //heder file a #include "b.h" class a { b objb; } //heder file b #include "a.h" class b { a obja; } vc++ can not complie these codes please tell me how can i do that?

      R Offline
      R Offline
      rabih_kai
      wrote on last edited by
      #2

      u cannot do this even if it compiles, object are wrong, just create a parent object class for both and inherite a & b classes from it then u publish an Object variable in both classes and on runtime u cast it to whatever u want...

      1 Reply Last reply
      0
      • R Reza Azizi

        i have 2 class a and b like this: //heder file a #include "b.h" class a { b objb; } //heder file b #include "a.h" class b { a obja; } vc++ can not complie these codes please tell me how can i do that?

        M Offline
        M Offline
        Mad__
        wrote on last edited by
        #3

        Try store not objects, but pointers: // header file a class b; class a { b* pObja; } // header file b class a; class b { a* pObja; }

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups