/ Published in: C++
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
#include <iostream> #include <string> template< class T > class Foo; template< class T> class Foo< T* > { public: Foo( const T *t ): t_( t ) {} void print() const { std::cout << *t_ << std::endl; } private: const T *t_; }; int main() { std::string s( "42" ); Foo< std::string* >( &s ).print(); }