Entry (main) method inside a class?

Bill Baxter dnewsgroup at billbaxter.com
Sun Mar 18 10:30:51 PDT 2007


Dejan Lekic wrote:

 > Well, I think it is very good to have main _inside_ a class I am
 > currently "playing with" during the development process (of the
 > class). Sure I can have a main() function in the same module and play
 > with the class there, but somehow I "feel" it belongs to the class
 > block. Obviously this is a matter of taste, so it does not really
 > matter whether we will have this "feature" in D or not. I just started
 > this thread because I thought it is somehow possible to do it...  :)

I don't get it.  If you like having main in a class so much just put it 
there and call it.  If you like Java, then apparently you like typing 
and this way you get to do even more of it! :-)

class MyClass
{
    public static void main(char[][] args) {
        writefln("Whee I'm main now!");
    }
}

void main(char[][] args) { MyClass.main(); }



More information about the Digitalmars-d mailing list