- Joined
- Oct 9, 2009
- Messages
- 9
- Reaction score
- 0
Hi all
I saw templated classes where is used pointers or const pointers as arguments.
I never though that it was possible and In my mind I only thought to template arguments as valid types or classes.
Is this a good approach ?
What about if I have functions having reference but my template argument are pointers?
Might I have some issue?
template< T >
class CA{
public:
void foo( const T& anObj ){
// do someting
}
};
void main(){
CA< const CB* > obj;
CB* ptr = new CB();
obj.foo( ptr );
}
I saw templated classes where is used pointers or const pointers as arguments.
I never though that it was possible and In my mind I only thought to template arguments as valid types or classes.
Is this a good approach ?
What about if I have functions having reference but my template argument are pointers?
Might I have some issue?
template< T >
class CA{
public:
void foo( const T& anObj ){
// do someting
}
};
void main(){
CA< const CB* > obj;
CB* ptr = new CB();
obj.foo( ptr );
}
Last edited: