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. C++ "friend" related

C++ "friend" related

Scheduled Pinned Locked Moved C / C++ / MFC
questionc++help
2 Posts 2 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.
  • P Offline
    P Offline
    pba_
    wrote on last edited by
    #1

    Hi , supposing that I have two classes : A and B . I declare a nested class in B called C. class A { /// } class B { /// class C { /// } ; } what is the problem : I want that the C class to be a friend of the A class. I can't write in the def. of class A friend class B::C , because B is not defined .Even if I define the B class before the A def. it's no good . I can't move the code of the B class declaration before the delcaration of A ( some other classes are between them ) . So , what can I do ? :)

    L 1 Reply Last reply
    0
    • P pba_

      Hi , supposing that I have two classes : A and B . I declare a nested class in B called C. class A { /// } class B { /// class C { /// } ; } what is the problem : I want that the C class to be a friend of the A class. I can't write in the def. of class A friend class B::C , because B is not defined .Even if I define the B class before the A def. it's no good . I can't move the code of the B class declaration before the delcaration of A ( some other classes are between them ) . So , what can I do ? :)

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      Try the following if all three classes are defined in one *.H file. // forward declaration class c; class A { friend class C; /// }; class B { /// class C { /// }; }; Otherwise, declare all three separately, and include C as the member of B.

      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