Overriding draw method for CCLayerColor

I have a class like so:

class Graph : public CCLayerColor {
public:
Graph();
~Graph();
>
void plotDataSet(DataSet data);
static Graph* create(float width, float height);
virtual void draw();
};

And override the draw method like so:

void Graph::draw()
{
>
this->getParent()>draw;
CCSize size = this
>getContentSize();
ccDrawColor4F(255, 255, 255, 255);
ccDrawLine(ccp(0,0), ccp(size.width, size.height));
>
}

Yet the layer fails to draw. If I stop overriding the draw method the CCLayerColor is renderend properly again. I have tried adding a this->getParent()->draw() call and it doesn’t help. Any ideas what my mistake is?

the parent is the object that this is inside-
that first line would theoretically draw another copy of the parent inside this one.

were you trying to call the draw function that you are overriding? the one inside CCLayerColor?

try:

void Graph::draw() {
CCLayerColor::draw();
}

that should do the normal drawing, and you could add stuff afterwards if you wanted.

It is more readable in other languages because of the keyword super but in C++, to call the overridden method, you need to call MyClass::myFunc*
In your case, it’s
CCLayerColor::draw();*

Thanks both of you, that solved my problem. It did confuse me as like you say, I’m used to the super keyword. I thought accessing MyClass::function() was equivalent to calling a static method. Obviously I need to study c++ in a bit more depth.