I have three classes:
Class Something
{...}
Class A
{
public:
A();
virtual ~A() = 0; //have also tried this as non-abstract
std::vector< unique_ptr<Something> > somethings; //have tried this just as std::vector<Something*> as well
};
class B : public A
{
B();
...
}
if I leave out the declaration of std::vector< Something* > somethings, from class B... then my compiler tells me that class class ‘B’ does not have any field named ‘somethings’.
So if I add it back in, and I try to reference it like so
A *a = new B();
for(auto it = a->somethings.begin(); it != a->somethings.end(); it++)
{
Draw((*it)->image,(*it)->x, (*it)->y, NULL, (*it)->angle);
}
It says that a->somethings is empty... even though if I print from B itself to tell me how many 'somethings' there are, it is accurately reporting the count. This is what led me to remove std::vector< unique_ptr > somethings; from class B to begin with, as I suspected it was somehow getting A's vector instead, even though it's abstract.
Bonus: This all works if I go B *b = new B(); just broke when I added the parent class A and made B inherit from it.