C++Talk.NET Forum Index C++Talk.NET
C++ language newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Template Instantiation and member templates.

 
Post new topic   Reply to topic    C++Talk.NET Forum Index -> C++ language (comp.lang.c++)
View previous topic :: View next topic  
Author Message
Guest






PostPosted: Fri Jan 27, 2006 9:32 pm    Post subject: Template Instantiation and member templates. Reply with quote



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





PostPosted: Fri Jan 27, 2006 9:32 pm    Post subject: Re: Template Instantiation and member templates. Reply with quote



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
Display posts from previous:   
Post new topic   Reply to topic    C++Talk.NET Forum Index -> C++ language (comp.lang.c++) All times are GMT
Page 1 of 1

 
Jump to:  
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


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.