From mboxrd@z Thu Jan 1 00:00:00 1970 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 1164f8,55db87e86e56fa6b,start X-Google-Attributes: gid1164f8,public From: bob@bsm.bioc.ucl.ac.uk (Bob MacCallum) Subject: DEC C++ template trouble. Date: 1996/03/13 Message-ID: <1996Mar13.174331.94206@ucl.ac.uk>#1/1 X-Deja-AN: 142561445 organization: University College London newsgroups: comp.sys.dec I'm not a regular reader of this group I'm afraid, but sadly there are no C++ people in my group. I hope someone can help. The basic problem is with the instantiation and/or linkage of class template member functions in separate *.C files (i.e. not inlined in the .H file). I thought the Online Documentation would help, but I can't even get the simplest case to work (as it does with the SGI DCC compiler). I'm sorry I don't have the version number, but cxx -V gives a whole load of numbers, many of them being 4.2.x.x If version 5.0 doesn't have this problem, it will be hard to obtain (one DEC and 20 SGIs, busy sysadmin). Here goes //// file entity.H template class entity { T item; public: entity(const T& newT) : item(newT) { } virtual void doSomething(); }; //// file entity.C #include "entity.H" template void entity::doSomething() { cerr << item << '\n'; } //// file test.C #include #include "entity.H" main() { entity fred(12345); fred.doSomething(); return 0; } //// compilation goes as follows bsmax01<325>% cxx test.C entity.C |& demangle test2.C: entity.C: ld: Error: Undefined: __vtbl_10entity__Ti Make sure that the first member function of 'entity' is defined. entity::doSomething(void) bsmax01<326>% I've tried combinations of #pragma define_template entity and the command-line option, but the only thing which makes this work is to have the body code for entity::doSomething in the header file. I would be very happy if someone can point out my obvious errors, thanks in advance, Bob. -- ++++++++++++++++++++++++++++++ Bob MacCallum ++++++++++++++++++++++++++++++ +++++++++++++++ Biomolecular Structure and Modelling Group ++++++++++++++++ ++++++++++++ Department of Biochemistry and Molecular Biology +++++++++++++ ++++++++++++++++ University College London, WC1E 6BT, UK ++++++++++++++++++