class MyClass
{
// something
vector<shared_ptr<AnotherClass>> my_vector;
};
class SecondClass
{
// something else
vector<shared_ptr<AnotherClass>> another_vector; // may have same elements with my_vector
};
Is this OK? Or how should I use shared pointers? And if anybody has a good guess what's causing the stack overflow, let me know.
boost::shared_ptr and stack overflow
I converted my program to use boost::shared_ptr instead of normal pointers. I have class with std::vector with shared pointers in it and when I clear the vector I got crash with stack overflow and access violation in the vector. This is my first time using shared pointers in a complex program so it's probably caused by my bad design.
I have something like this:
A stack overflow frequently indicates infinite recursion. Look at the call stack. Does the AnotherClass destructor affect the vectors in MyClass or SecondClass?
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement