Why does forward declaration not work with classes?
        Posted  
        
            by eSKay
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by eSKay
        
        
        
        Published on 2010-04-16T04:37:41Z
        Indexed on 
            2010/04/16
            4:43 UTC
        
        
        Read the original article
        Hit count: 480
        
int main() {
    B bb;                           //does not compile (neither does class B bb;)
    C cc;                           //does not compile
    struct t tt;                    //compiles
    class B {};
    struct s { struct t * pt; };    //compiles
    struct t { struct s * ps; };
    return 0;
}
class C {};
I just modified the example given here.
Why is that the struct forward declarations work but not the class forward declarations?
Does it have something to do with the namespaces - tag namespace and typedef namespace? I know that the structure definitions without typedefs go to tag namespace. 
Structures are just classes with all public members. So, I expect them to behave similarly.
© Stack Overflow or respective owner