By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
449,312 Members | 1,850 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 449,312 IT Pros & Developers. It's quick & easy.

Template Instantiation and member templates.

P: n/a
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.

Jan 27 '06 #1
Share this Question
Share on Google+
1 Reply


P: n/a
am******@gmail.com wrote:
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
Jan 27 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.