jump to navigation

Sentirei saudades Junho 18, 2008

Posted by Humberto B in C++.
add a comment

De escrever coisas do tipo:

TypedCollection<const char*> lista;
lista = "uma", "lista", "de", "palavras";

Powered by:

template<class T> class TypedCollection
{
protected:
   std::vector<T> m_InnerVector;

public:
   TypedCollection() {}
   TypedCollection(T initialValue)
   {
      this->m_InnerVector.push_back(initialValue);
   }

   TypedCollection<T>& operator,(T elem)
   {
      this->m_InnerVector.push_back(elem);
      return *this;
   }
};

Vida longa ao C++!