import stdlib;
using stdlib;
interface IHello
{
method IHello();
method Set(int);
method int Get();
}
class CHello : IHello
{
method CHello() { m_Value = 0; }
method Set(int v) { m_Value = v; }
method int Get() { return m_Value; }
method NotInInterface() { m_Value *= 5; }
int m_Value;
}
class CFoo : IHello
{
method CFoo() { m_String = ""; }
method Set(int v) { m_String = v; }
method int Get() { return (int) m_String; }
string m_String;
}
function string main(const string[] args)
{
CHello hello = new CHello();
hello.Set( 101 );
int x = hello.Get();
hello.NotInInterface();
IHelloPrint( hello );
CFoo foo = new CFoo();
foo.Set( 202 );
int y = foo.Get();
IHelloPrint( foo );
IHello ihello = hello;
ihello.Set( 303 );
int z = ihello.Get();
IHelloPrint( ihello );
return "";
}
function IHelloPrint(const IHello hello)
{
print("* The given object is a ");
if( typeof(hello) == typeof(CHello) )
{
print("CHello\n");
}
else if( typeof(hello) == typeof(CFoo) )
{
print("CFoo\n");
}
printf( "* IHello::Get() returns %d\n", hello.Get() );
}