lundi 27 juillet 2015

Forward declaration within class in C++

Have a question about forward declration in C++

class Outer::Inner; // not valid. error
class Outer {
    Inner * inn; // not valid, needs forward declaration.
    class Inner {
    }
}

But when implemented like this:

class Outer::Inner; // not valid. error
class Outer {
    class Inner; // forward-"like" declaration within class
    Inner * inn;
    class Inner {
    }
}

Compiles ok. But I have never saw implementationa like this before (because of my small experience in C++), so I'm interesting if this wan't cause some kind of error or unpredictable behaviour in future.

Thanks All in advance)

Aucun commentaire:

Enregistrer un commentaire