Henrik
Henrik

Reputation: 1157

How do I extend a class?

I have a class: Model, with many functions, such as draw(), rotate() etc.

now i have another class called Cube that i want to be able to work the same way as Model.

I have this in my Cube class constructor:

Model m3d = new Model();        
m3d.build(obj);

So what i want is to be able to in another class call something like:

mCube.draw();

and m3d will perform draw().

Upvotes: 4

Views: 162

Answers (1)

Naftali
Naftali

Reputation: 146302

Ok. So do this in the class call:

class Cube extends Model {...}

Then you can do:

Cube mCube = new Cube();        
mCube.build(obj);
mCube.draw();

Upvotes: 5

Related Questions