Archived

This forum has been archived. Please start a new discussion on GitHub.

About Classes as Unions

the .ice file is

class base
{
int d;
};
class stringbase extends base
{
string s;
};
class Hello
{
nonmutating void sayHello(base i);
idempotent void shutdown();
};
....

In the implement file , in the function

void sayHello(base i);
How can I dynamic_cast or static_cast the base pointer to stringbase pointer?

Comments

  • benoit
    benoit Rennes, France
    In C++, you can use the smart pointer dynamicCast method:
       void sayHello(basePtr i)
       {
             stringbasePtr s  = stringbasePtr::dynamicCast(i);
       }
    

    In Java, you can just do a regular dynamic cast:
       void sayHello(base i)
       {
             stringbase s = (stringbase)i;
       }
    

    Benoit.
  • It's ok
    Thank a lot .