Advertisement

Polymorphism : dynamic method resolution

Started by September 27, 2010 05:44 AM
1 comment, last by Zaran 14 years, 2 months ago
Hi,

I would like to do something like this :

class A
{
void method(){ something };
}

class B : A
{
void method(){ something else };
}

B objectB;
A@ copy = @objectB;
copy.method();

I would like the last line to call the method as it is defined in class B. In C++ this can be done by using virtual function. Can this be done in AngelScript, if not, is there some workaround ?
This works in AngelScript as well. All script class methods in AngelScript are automatically virtual. Nothing special needs to be done to do what you want.

AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game

Advertisement
Indeed it woks. It was another error in my code which made me think it wasn't possible. I should have tested my code mmore carefully.

Thx a lot.

This topic is closed to new replies.

Advertisement