开发者

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();
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜