24.12 TEMPLATE BASED CLASSES

template<class T, int N>

class Matrix

    { protected:      T X[N][N];    public :      void multiply(Matrix A, Matrix B, Matrix &C);      void show();      Matrix();      Matrix(T box[9]);      void set(int i, int j, T val) ;      T get(int i, int j ) ;  } ;  template<class T>

class Node

    { public:      T key;      Node * next;      Node(T n) ; //for key  };  template <class T>

class LinkList

    { protected :      Node<T> *root ;      Node<T> *tail ;    public :      LinkList();      void addNode( T M);      void show();  };  template <class T>

class Stack : public LinkList<T>

    { public :      void pop(T & item);      void push( T item);  } ;

Get Object Oriented Programming with C++, Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.