Advertisement

A rare question

Started by August 19, 2002 11:00 PM
4 comments, last by wingcom 22 years, 2 months ago

  
#include <iostream>

class World
{
public:
  World() { std::cout << "Hello!\n"; }
  ~World() {std::cout << "Good Bye!\n"; }
};

World TheWorld;

void main() {}
  
i''m using Dev-C++ 4.9.5.0 to compile the above code but i doesn''t compile at all but by compiling it under VC it works. After i change the void main() {} -> int main(int argc, char *argv[]) {return 0;} it compiles, from what i know, Dev-C++ is the most compliant to C++ compiler in the market, so is it a requirement for us to explicitly code the two parameters in main() to compile the program, does the two parameters a standard of C++?
Nothing to do, try complimenting someone, it will make you feel better!
The problem is the void return of main, it''s not standard.
The standard only allows two forms of "main":

int main(void);

or

int main(int argc, char *argv[]);


Kami no Itte ga ore ni zettai naru!
神はサイコロを振らない!
Advertisement
thanks man, this really helps
Nothing to do, try complimenting someone, it will make you feel better!
<nitpicking>
Technically the standard allows more forms of main than that, but all forms should have an int return-type.
</nitpicking>

-Neophyte
just do whatever compiles for the main and forgetaboutit, useful command line parameters in games are few and far

Most of the time the IDE writes it for you anyway
Wha? You don''t have to have a ''return'' statement in main()???

I feel so stupid.

This topic is closed to new replies.

Advertisement