| View previous topic :: View next topic |
| Author |
Message |
gopal Guest
|
Posted: Sat Jun 17, 2006 9:10 am Post subject: class templates & constructor defn outside the class |
|
|
I have the following class template declaration
//class template declaration
template <class T> class A {
public:
T t1;
A(T);
};
I would like to define the class A constrcutor outside. Any help
please?
Regards
JK |
|
| Back to top |
|
 |
Ian Collins Guest
|
Posted: Sat Jun 17, 2006 9:10 am Post subject: Re: class templates & constructor defn outside the class |
|
|
gopal wrote:
| Quote: | I have the following class template declaration
//class template declaration
template <class T> class A {
public:
T t1;
A(T);
};
I would like to define the class A constrcutor outside. Any help
please?
Well that all depends on how your compiler looks for class template |
member definitions. If it supports 'export' or uses other means to
locate them, you can put the definition in an appropriate source file.
Otherwise you have to include the definition in the header.
template <class T>
A<T>::A( T )
{
...
}
--
Ian Collins. |
|
| Back to top |
|
 |
gopal Guest
|
Posted: Sat Jun 17, 2006 9:10 am Post subject: Re: class templates & constructor defn outside the class |
|
|
Hi tried the above code and i got the following error
1. __ctor' : is not a member of 'A<T>
2. A<T>' : template-class-id redefined as a global function
3. initializing' : cannot convert from 'const int' to 'class
A<int>
Ian Collins wrote:
| Quote: | gopal wrote:
I have the following class template declaration
//class template declaration
template <class T> class A {
public:
T t1;
A(T);
};
I would like to define the class A constrcutor outside. Any help
please?
Well that all depends on how your compiler looks for class template
member definitions. If it supports 'export' or uses other means to
locate them, you can put the definition in an appropriate source file.
Otherwise you have to include the definition in the header.
template <class T
A<T>::A( T )
{
..
}
--
Ian Collins. |
|
|
| Back to top |
|
 |
|