how to get an extern class that extends bbObject and not void?

About Monkey 2 Forums Monkey 2 Programming Help how to get an extern class that extends bbObject and not void?

This topic contains 4 replies, has 3 voices, and was last updated by  codifies 2 years, 5 months ago.

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #4002

    abakobo
    Participant

    I could not compile some code with an external class that doesn’t extends void but bbObject: “(source type is not polymorphic)” error message
    In the manual it looks like it’s possible:

    Extern classes are assumed by default to be real monkey2 classes – that is, they must extend the native bbObject class.

    However, you can override this by declaring an extern class that extends Void. Objects of such a class are said to be native objects and differ from normal monkey object in several ways:

    A native object is not memory managed in any way. It is up to you to ‘delete’ or otherwise destroy it.

    A native object has no runtime type information, so it cannot be downcast using the Cast<> operator.

    [/crayon] [/crayon]

    Tried with “extends Object” and “extends monkey.types.Object” too
    With “extends void” the code will work.

    error message:

    [/crayon]
    Attachments:
    1. ext_non_void.zip
    #4012

    Mark Sibly
    Keymaster

    The c++ class must actually extend bbObject, eg:

    #5200

    codifies
    Participant

    the destructor is commented out?

    if there needs to be code in the destructor do you have to

    what should I do if I need to have code in the “Foo” destructor ?

    #5222

    Mark Sibly
    Keymaster

    In this case, there is no need for a dtor as it’s a NOP and bbObject already declares a virtual dtor.

    But you can add dtor code if you want. There is no need/way to call super.dtor as c++ already does this for you automatically after your dtor executes.

    #5223

    codifies
    Participant

    yeah, gotcha, cheers Mark

Viewing 5 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic.