Im currently working on creating a game engine and I'm having a bit of trouble with one thing, would love some fresh eyes on this problem, I'll give an example. It's semi-psuedo code.
Class_A
{
public:
void fill()
{
vec.pushback(5);
vec.pushback(6);
}
std::vector<int> vec;
}
#include Class_A
Class_B
{
public:
Class_A object;
void check()
{
std::cout << object.vec[0] << std::endl; // Gives me out of range, because
// the size of the vec is 0 from this class. Why cant how can I get around
// the problem?
}
}
Edit: Class A fill is being called before Class B check. I've even printed out the size at the end of the function fill() and it says 2.
That makes sense, I tried something and what you said was the problem, just have to find a way to change things so it's implemented correctly. Thank you.