
template classes with static members
template <typename T>
struct AStatic
{
static T object;
Quote:
};
// still in the header:
template <typename T>
T AStatic<T>::object; // default initialized
// or: T AStatic<T>::object( 34.5, "help" ); // constructor required
// or: T AStatic<T>::object = 42; // T convertible from int/non-explict
constructor required
// in source file
class Foo {};
void bar(Foo&);
void foobar()
{
bar(AStatic<Foo>::object);
Quote:
}
HTH
-- J?rg Barfurth
Quote:
> Hello!
> Does anybody know how to make the template class with static members
> and not to cause the LNK2001 "Unresolved external"? Note: I have to
> include the header file with my tempate into several *.cpp files.
> Best regards, Sergey Surkov