bug-gplusplus
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Deriving from class nested in template


From: Indiana Epilepsy and Child Neurology
Subject: Deriving from class nested in template
Date: Mon, 25 Nov 2002 16:58:19 -0500

It seems to me this should be OK; regardless, there's a bug in g++
which causes a Segmentation fault if you try to compile it.  What I'm
wondering is whether this is legal C++:

// Example 1.

template<class T>
struct Outer { struct Middle { struct Inner; }; };

template<class T>
struct Outer<T>::Middle::Inner : public Outer<T>::Middle { };

// . . .

// End example 1

I find it especially interesting that if you define class Inner
inline, it compiles OK:

// Example 2.

template<class T>
struct Outer { struct Middle { struct Inner: public Outer<T>::Middle {
}; }; };

// . . .

// End example 2

It seems like THIS would be illegal, because Inner is deriving from
Middle, which is not fully defined at the time.  I'd expect the first
example to be the "legal" solution.

Can anyone clarify this for me?
-- 
Don Stauffer, Office Manager
Indiana Epilepsy and Child Neurology, Inc.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]