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 = ne开发者_StackOverfloww 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()
.
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();
精彩评论