Topic: Ordering of typedefs and templates


Author: deline@parc.xerox.com (Robert DeLine)
Date: Sat, 7 Aug 1993 21:09:56 GMT
Raw View
Simple question: is the following C++ program legal?


        template <class T>
        class Foo
        {
          public:
            Foo(T i);
        };

        typedef Foo<float> Bar;

        template <class T>
        Foo<T>::Foo(T i)
        {
        }

        main()
        {
            Bar b(3.0);
        }


Two versions of GCC (2.3.3 and 2.4.5) on a Sun give a link error that
Foo<float>::Foo(float) is not defined.  The fact that it's a
constructor is irrelevent; I can get the same error with any method
that's defined *after* the typedef.

So is this a bug in GCC or a shortcoming of C++?

Thanks a bunch,

Rob DeLine