class A{
public:
template<typename Obj>
class MyVec{
//some methods...
};
MyVec<A> a; //-> doesnt work
//vector<A> a; //using stl vector-> this works
};
class B{
public:
void someMethod();
private:
A::MyVec<A> b;
};
In the method, when I do sth like:
void someMethod(){
//...
b[0].a.pushback(element);
//...
}
In class A if i use std::vector everything works properly. But when i use nested class it doesn’t work.
I’ve taken your code and modified it as minimally as possible to get something that compiles. This seems to work fine. And so the error is not in the code you have shown us.
When I run this I get:
Which is what I’d expect. (one push in the constructor of B and one push to the internal object from someThing)
You can view the result here:
http://ideone.com/BX8ZQ