Declaring STL Data Structures such as Vector in the .h

Posted by sc_ray on Stack Overflow See other posts from Stack Overflow or by sc_ray
Published on 2010-03-26T18:47:57Z Indexed on 2010/04/05 21:53 UTC
Read the original article Hit count: 246

I am trying to declare a private Data Structure such as the Vector in my C++ header file which I want to eventually use within the method implementation of my .cpp.

An example would be my header "SomeClass.h" where I have:

class SomeClass
{
  private:
  Vector<T> myVector;
  public:
  void AddTtoMyVector(T add);
}

And in my .cpp which is "SomeClass.cpp", I have the following:

#include "SomeClass.h"

SomeClass::AddTtoMyVector(T add)
{
     myVector.Push_back(add);
}

Would the syntax here work? Or is there a different way of declaring and populating such structures?

© Stack Overflow or respective owner

Related posts about c++

Related posts about data-structures