Here is an example


#include <iostream>
#include <vector>

template <typename T>
class MyVector : public std::vector<T>
{
 // Bingo. You already have all the properties of a std::vector

 // Now suppose You want to add a new method
 // which prints all the members of the container.
 public:
 void printAll (void)
 {
  typename std::vector<T>::iterator it;

  for (it = this->begin (); it != this->end (); it++) ------- Array 
   std::cout << *it << "\t";

  std::cout << std::endl;
 }
};

int main (void)
{
 MyVector<double> v;

 v.push_back (1.1); // inherited from std::vector
 v.push_back (2.5); // inherited from std::vector
 v.push_back (3.9); // inherited from std::vector

 v.printAll (); // you have defined it yourselves.
}
Designed By Blogger Templates | Templatelib & Distributed By Blogspot Templates