exc_bad_access on virtual method?

Started by
1 comment, last by Kitt3n 14 years, 3 months ago
So I have this hierarchy of classes for my UI. The way this is setup now is: FPSCounter is a Label is a Control in my Control class I define virtual void update() { } Now way down in FPSCounter, I want to implement the update method. However, when I iterate through a list of Controls (which currently only consists of the FPSCounter), I get a exc_bad_access. What would cause this?
void Container::updateChildren() {
	if(!hasChildren()) {
		return;
	}
	
	std::list<ControlPtr>::iterator iter;
	for(iter = _children.begin(); iter != _children.end(); iter++) {
		(*iter)->update(); // <- EXC_BAD_ACCESS
	}
}
ControlPtr is a boost::shared_ptr<Control>
Advertisement
Okay...well....after I turned on my computer this morning, I didn't have the problem. Weird.
Maybe you called your update function on a null-pointer?
Next time youn get the assert, look at the contents of iter

I'd also add an assert - just to be sure ^^
visit my website at www.kalmiya.com

This topic is closed to new replies.

Advertisement