Thread: main in a class?

  1. #1
    Registered User
    Join Date
    May 2005

    main in a class?

    Ok, my past C++ experience has all been in the Windows environment using MFC so I've never really worried about a main(...) function as the App Wizard took care of all that for me.
    When writing a console app with a main(...) function, is it ever reasonable to put main(...) in a class as a member function or should it always be kind of hanging out there as a global so to speak? If it can be put in a class, how does the OS know where the entry-point for the exe is?

  2. #2
    Frequently Quite Prolix dwks's Avatar
    Join Date
    Apr 2005
    I don't think you can put main() in a class (except in Java).

    Seek and ye shall find. quaere et invenies.

    "Simplicity does not precede complexity, but follows it." -- Alan Perlis
    "Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
    "The only real mistake is the one from which we learn nothing." -- John Powell

    Other boards: DaniWeb, TPS
    Unofficial Wiki FAQ:

    My website:
    Projects: codeform, xuni, atlantis, nort, etc.

  3. #3
    Registered User
    Join Date
    Jan 2005
    Just leave it global and have it call the class member function you want to run.

  4. #4
    Registered User
    Join Date
    May 2005
    That's kind of what I figured I'd end up doing. Now for a twist on the question though, how do I model this type of program (for instance in Rational Rose)? The classes are easy, but how do you model the "global" stuff? This is probably the wrong forum to ask this.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Inherite nonvirtual class functionality
    By DrSnuggles in forum C++ Programming
    Replies: 2
    Last Post: 04-30-2009, 01:52 PM
  2. Replies: 3
    Last Post: 10-31-2005, 12:05 PM
  3. My Window Class
    By Epo in forum Game Programming
    Replies: 2
    Last Post: 07-10-2005, 02:33 PM
  4. structure vs class
    By sana in forum C++ Programming
    Replies: 13
    Last Post: 12-02-2002, 07:18 AM