• Advertisement
Sign in to follow this  

Polymorphism : dynamic method resolution

This topic is 2762 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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 ?

Share this post


Link to post
Share on other sites
Advertisement
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement