title: Int main inside a class
body: <p>Simple question, how can I run a program having main inside a class?
  I have a code:</p>
  
  <p>MojSwiat2.cpp:</p>
  
  <pre><code>int Main::main() {
      // code 
      return 0;
  }
  </code></pre>
  
  <p>And MojSwiat2.h:</p>
  
  <pre><code>class Main {
  public:
      int main();
  };
  Main run;
  int Main::main() { // with this I have error: function int Main::main(void) already has a body
      run.main();
  } // and without I got unresolved external symbol _main referenced in function __tmainCRTStartup
  </code></pre>
  
  <p>Reason I need to do this: <a href="https://stackoverflow.com/questions/23231789/accessing-protected-members-of-class-from-main/23231873?noredirect=1#comment35544236_23231873">Accessing protected members of class from main</a></p>