S
Skybuck Flying
Question:
How to declare class template constructor and destructor outside the class ?
(I cannot find a good example on the internet or in the books (from years
ago) or in the help files).
How to modify this basic example so the link errors are gone ?
// TestProgram.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
template <class GenericType>
class Ttest
{
private:
GenericType mField1;
GenericType mField2;
public:
Ttest();
~Ttest();
};
Ttest::Ttest()
{
}
Ttest::~Ttest()
{
}
int _tmain(int argc, _TCHAR* argv[])
{
Ttest<int> a;
Ttest<int> b;
// getting link errors.
return 0;
}
Bye,
Skybuck.
P.S.: Most examples declare them inside the class declaration which is quite
bad programming style, it clutters it badly, this should have never been
allowed in c++, but that's my personal oppinion fortunately Delphi does
not have it, keep it consistent I say... all inside or all outside, not half
half.
How to declare class template constructor and destructor outside the class ?
(I cannot find a good example on the internet or in the books (from years
ago) or in the help files).
How to modify this basic example so the link errors are gone ?
// TestProgram.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
template <class GenericType>
class Ttest
{
private:
GenericType mField1;
GenericType mField2;
public:
Ttest();
~Ttest();
};
Ttest::Ttest()
{
}
Ttest::~Ttest()
{
}
int _tmain(int argc, _TCHAR* argv[])
{
Ttest<int> a;
Ttest<int> b;
// getting link errors.
return 0;
}
Bye,
Skybuck.
P.S.: Most examples declare them inside the class declaration which is quite
bad programming style, it clutters it badly, this should have never been
allowed in c++, but that's my personal oppinion fortunately Delphi does
not have it, keep it consistent I say... all inside or all outside, not half
half.