Topic: template class c-tor / d-tor
Author: dietmar.kuehl@claas-solutions.de
Date: 1998/04/17 Raw View
Hi,
In article <35347EC6.16059A5C@rabatin.com>,
Arthur Rabatin <research@rabatin.com> wrote:
> I get a linker error
>
> unresolved external symbol "public: __thiscall
> CMatrix<double>::~CMatrix<double>(void)"
> "unresolved external symbol public: __thiscall
> CMatrix<double>::CMatrix<double>(void)"
> template < class T > class CMatrix
> {
> public:
> CMatrix ( );
> CMatrix ( const CMatrix& _That );
> CMatrix& operator = ( const CMatrix& _That );
> ~CMatrix ( );
> // some other stuff
> };
> template <class T> CMatrix<T>::CMatrix ( )
> {
> // intentionally left blank
> }
I guess, you separated declaration and definition (eg. the declaration into a
header and the definition into a source file) and the definition doesn't get
instantiated. Actually, it is not even expected to be instantiated in this
case: Either you implement your template inline (whether in the class or not
doesn't matter), you implement your template as "export" (which is not yet
support by any compiler AFAIK), or you use explicit instantiation.
Probably, the easiest approach to fix this problem is to include the source
file in the header for compilers which do not implement some magic taking care
of instantiations.
-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/ Now offering spam-free web-based newsreading
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://reality.sgi.com/austern_mti/std-c++/faq.html ]
Author: Arthur Rabatin <research@rabatin.com>
Date: 1998/04/19 Raw View
I've got it now! I have put template decleration and defintion into *.h /
*.cpp resp, which causes the error!
Thanks for the messages (Danke fuer die Hinweise - an die deutschen Freunde)
Gruesse / Greetings
Arthur
Arthur Rabatin wrote:
> Hi,
> I'm struggling with the following under MS VC++ (5.0 Service Pack 3).
> I get a linker error
>
> unresolved external symbol "public: __thiscall
> CMatrix<double>::~CMatrix<double>(void)"
> "unresolved external symbol public: __thiscall
> CMatrix<double>::CMatrix<double>(void)"
>
> when declaring the following simple template class as CMatrix < double >
> lMatrix;
>
> This is the class decleration
> ==================
>
> template < class T > class CMatrix
> {
> public:
> CMatrix ( );
> CMatrix ( const CMatrix& _That );
> CMatrix& operator = ( const CMatrix& _That );
> ~CMatrix ( );
> // some other stuff
> };
>
> This is the class definition
> =================
>
> template <class T> CMatrix<T>::CMatrix ( )
> {
> // intentionally left blank
> }
>
> // other implementations .. same thing
>
> According to the documentation I have availably (incl the MS docu that
> comes with VC++) the defintion should be OK; there are also no compiler
> errors for the individual source files.
> This is all within a simple 3 file project and main() routine, so
> nothing across libraries.
>
> Is this a bug or a feature or have I forgotten something?
>
> Any hints highly appreciated
.................................
Rabatin Investment Technology Ltd
http://www.rabatin.com
research@rabatin.com
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://reality.sgi.com/austern_mti/std-c++/faq.html ]
Author: Arthur Rabatin <research@rabatin.com>
Date: 1998/04/16 Raw View
Hi,
I'm struggling with the following under MS VC++ (5.0 Service Pack 3).
I get a linker error
unresolved external symbol "public: __thiscall
CMatrix<double>::~CMatrix<double>(void)"
"unresolved external symbol public: __thiscall
CMatrix<double>::CMatrix<double>(void)"
when declaring the following simple template class as CMatrix < double >
lMatrix;
This is the class decleration
==================
template < class T > class CMatrix
{
public:
CMatrix ( );
CMatrix ( const CMatrix& _That );
CMatrix& operator = ( const CMatrix& _That );
~CMatrix ( );
// some other stuff
};
This is the class definition
=================
template <class T> CMatrix<T>::CMatrix ( )
{
// intentionally left blank
}
// other implementations .. same thing
According to the documentation I have availably (incl the MS docu that
comes with VC++) the defintion should be OK; there are also no compiler
errors for the individual source files.
This is all within a simple 3 file project and main() routine, so
nothing across libraries.
Is this a bug or a feature or have I forgotten something?
Any hints highly appreciated
Art
.................................
Rabatin Investment Technology Ltd
http://www.rabatin.com
research@rabatin.com
---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://reality.sgi.com/austern_mti/std-c++/faq.html ]