pointer in template argument

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 );
}
 
Last edited:

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,774
Messages
2,569,598
Members
45,150
Latest member
MakersCBDReviews
Top