code tags would help...
http://cplusplus.com/articles/firedraco1/
Anyway
Well, even if they are inherited they are part of the class, don't they? |
You're kind of missing the point of OOP design. The idea is to have a class manage itself and not have users of the class be responsible for managing it. A class should "just work"
Here, PH does not "just work" because BS is assuming the responsibility for its members.
Case in point: this problem you're having could be anywhere in this BS class or it could be in your PH class. So now in order to find the problem, we basically have to scour your entire program looking for bugs rather than just limiting ourselvse to a single class.
Anywho... I don't see where these members are allocated with new (I'm assuming that's in PH somewhere) so I can't tell whether or not you're going out of bounds.
I do see an problem that might be related though:
Your copy ctor is faulty. You're just copying the pointers. If you do something like this:
1 2 3 4
|
BS a;
BS b(a); // make a copy;
// BANG YOU'RE DEAD
| |
when a is destroyed, it will delete[] the buffers. Then when b is destroyed it will delete[]
the same buffers (because all you did was copy the pointer, not create a new buffer). Deleting the same buffer multiple times = explode.
Plus -- why is BS constructing PH's members? PH should be constructing PH's members!
Also the names of your classes could use some improvement. What are BS and PH supposed to be?