Hi.
I have a code that doesn't compile. And I know the reason it doesn't. I'd like to ask if anyone has a workaround or some special trick to make it work.
If anyone has an idea that would make this 'inheritance' code compile, please let me know. I know there are other options to structure the templates. However, I really need that classes A and B are defined as described above.Code:template <class T>
class A
{
typedef typename T::MyInt MyInt;
};
template <class T>
class B : public A<B<T> >
{
public:
typedef int MyInt;
};
template <class T>
class C
{
public:
typedef int MyInt;
};
int main(int argc, char* argv[])
{
// This compiles fine, which is natural.
C<A<int> > c;
//This does NOT compile, since by the time A is defined, B has not
//defined the tipe MyInt yet, which is also easy to see. Because B inherits
//from A.
B<int> b;
}
Thanks.
