struct declaration into another struct

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • slocum

    struct declaration into another struct

    I have a struct like that

    struct A {
    struct B {
    .....
    }
    ...
    }

    I have to declare previously all that struct and their friends

    struct A;
    friend struct A;

    but how to declare struct B and which is declared into struct A ?

    struct A::B; ?
    friend struct A::B ?

    it doesn't work...
  • slocum

    #2
    Re: struct declaration into another struct

    On 11 Kwi, 08:42, "Jim Langston" <tazmas...@rock etmail.comwrote :
    slocum wrote:
    I have a struct like that
    >
    struct A {
    struct B {
    .....
    }
    ...
    }
    >
    I have to declare previously all that struct and their friends
    >
    struct A;
    friend struct A;
    >
    but how to declare struct B and which is declared into struct A ?
    >
    struct A::B; ?
    friend struct A::B ?
    >
    it doesn't work...
    >
    What doesn't work? The following compiles for me:
    >
    struct A
    {
    friend struct B;
    struct B
    {
    int x;
    };
    int y;
    >
    };
    >
    struct C
    {
    friend struct A::B;
    >
    };
    >
    int main()
    {
    >
    }
    >
    Does this answer your question?
    >
    --
    Jim Langston
    tazmas...@rocke tmail.com
    and what if struct A and B are template ? How to declare a friend for
    nested template struct ?
    template <classfriend struct A::B or what ????

    Comment

    Working...