I have a class called Thing that defines vector<string> stuff.
I have no problem declaring anything I want inside "class Thing" itself or functions from it, like "void Thing::bob" works fine. My problem is when I inherit this class. For some reason I get my program terminated.
pseudocode:
Class Thing
{
protected:
vector<string> stuff;
private:
constructers();
~destructors();
};
Thing::constructors()
{
stuff //do whatever I want with it without problems.
}
Class Foo : Public Thing
{
private:
constructers();
~destructors();
};
Foo::constructers()
{
stuff //can't mess with it.
cout << stuff.back(); //this would give me a runtime error.
}
In my "Thing::constructors()" above in my pseudocode I'm not doing anything fancy with vector<string> stuff. I'm just adding variables too it like "house" "farm" and your standard strings. They display with std::cout, but not when it's inherited too Foo.
Does this have to do with the behaviors of vectors or could there possibly be a memory leak with my program? Perhaps I’m just declaring my vector<string> stuff wrong.