#include <iostream> template <class T> // (1) class B { public: void foo(T* t); // (2) }; class T // (3) { public: int i; }; void B<T>::foo(T* t) // (4) { std::cout << t->i << std::endl; } int main() { B<T> b; // (5) T t; t.i = 3; b.foo(&t); }
(1) : template(2) : template(3) : class(4) : template(5) : classIt is important to distingiush exactly template from class(including structure or basic ordinary type) in C++ code.
Post a Comment
1 comment:
(1) : template
(2) : template
(3) : class
(4) : template
(5) : class
It is important to distingiush exactly template from class(including structure or basic ordinary type) in C++ code.
Post a Comment