This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Q) link error of template class


On Tue, May 08, 2001 at 11:03:52PM +0900, ?????? wrote:
> Hi,
> 
> I compile the source code with -frepo option as manual writes.
> But I have link errors as follows
> 
> 
> 
> BClass<STRT>::func1(void) testout.o
> BClass<STRT>::func1(void) testout.o
> ld : fatal : Symbol referencing errors. No out written to testout
> collect2: ld returned 1 exit status
> *** Error code 1
> make: Fatal error: Command failed for target 'testout'
> 
> 
> 
> 
> Source code is as follows
> This code  is compose of  three files(AClass.cpp, BClass.cpp, Main.cpp)
> 
> 
> 
> typedef struct {
>     int i;
> } STRT;
> 
> template<class T>
> class AClass {
> public :
> };
> 
> template<class T>
> class BClass : public AClass<T>
> {
> public :
>     void func1(void);
>     void func2(void);
> };
> 
> int main(int argc, char **argv)
> {
>        BClass<STRT> *a = new BClass<STRT>
> }
> 
> 
> Let me know how to solve the problem.
> 
Other than the fact you need a semicolon after ...new BClass<STRT>
This compiles fine here, 2.95.4(20010506) and 3.0(20010426).

Gordon Sadler


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]