Links

Categories

Tags


« | Main | »

Static typing

By Jewe | October 29, 2012

// define a new type
class Foo
{
    method Foo() { }
}

// define another new type
class Bar
{
    method Bar() { }
}

function string main(const string[] args)
{
    Foo foo = new Foo(); // make a Foo
    Bar bar = new Bar(); // make a Bar

    foo = bar;           // ERROR: Incompatible types - This won't work
                         // unless we add a constructor for 'Bar' to 'Foo'
                         // or a convertor for 'Foo' to 'Bar'

    return "";
}

Topics: code examples | Comments Off on Static typing

Comments are closed.