Given a class template:
template<class T> class vehicle { public: vehicle() { /* ... */ } // constructor ~vehicle() {}; // destructor T kind[16]; T* drive(); static void roadmap(); // ... };
and the declaration:
vehicle<char> bicycle; // instantiates the template
the constructor, the constructed object, and the member
function drive() can be accessed with any of the following (assuming the
standard header file <string.h> is included in the program file):
/------------------------------------------------------------------------------\ | constructor | "vehicle<char> bicycle; | | | // constructor called automatically | | | // object bicycle created" | |-------------------------------+----------------------------------------------| | object "bicycle" | "strcpy (bicycle.kind, "10 speed"); | | | bicycle.kind[0] = '2';" | |-------------------------------+----------------------------------------------| | function "drive()" | "char* n = bicycle.drive();" | |-------------------------------+----------------------------------------------| | function "roadmap()" | "vehicle<char>::roadmap();" | \------------------------------------------------------------------------------/