 |
C++Talk.NET C++ language newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Guest
|
Posted: Fri Jan 27, 2006 9:32 pm Post subject: Template Instantiation and member templates. |
|
|
I have something like this.
typedef enum TYPES{ X =0, Y,
Z,
MAX};
template <typename T>
class A
{
public:
typedef T obj;
A(){ }
~A() { }
template < int N>
void Open();
template < int N>
void Close();
private:
obj Object;
};
then I have
template<>
A<SomePreDefinedObject>::A()
{
// call member function of SomePreDefinedObject
}
template<>
template<int N>
A<SomePreDefinedObject>::Open()
{
ASSERT(N < MAX);
// call member function of SomePreDefinedObject
}
template<>
template<int N>
A<SomePreDefinedObject>::Close()
{
ASSERT(N < MAX);
// call member function of SomePreDefinedObject
}
template<>
template<>
A<SomePreDefinedObject>::Open<MAX>()
{
// call member function of SomePreDefinedObject
}
template<>
template<>
A<SomePreDefinedObject>::Close<MAX>()
{
// call member function of SomePreDefinedObject
}
now in main I have
main()
{
A<SomePreDefinedObject> O;
O.Lock<MAX>; //everything is fine //line 1
O.Lock<X>; // I get linker error // Line 2
}
Anyone knows why I could be getting linker error for Line 2 whch says
Lock and Unlock not found? I have the memner template defined for all
values except MAX and then for MAX it is specialized.
Thanks. |
|
| Back to top |
|
 |
Victor Bazarov Guest
|
Posted: Fri Jan 27, 2006 9:32 pm Post subject: Re: Template Instantiation and member templates. |
|
|
amparikh (AT) gmail (DOT) com wrote:
| Quote: | I have something like this.
[...]
now in main I have
[...]
Anyone knows why I could be getting linker error for Line 2 whch says
Lock and Unlock not found? I have the memner template defined for all
values except MAX and then for MAX it is specialized.
|
Please post _real_ code with which you have troubles. Read FAQ section 5.
V |
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|