User forums > General (but related to Code::Blocks)
Sugesstion about small changes in standard cpp code.
rickg22:
Yes, but remember hello world examples are made for NEWBIES :). Teaching them a little won't hurt anyone.
Michael:
--- Quote from: rickg22 on December 14, 2005, 08:29:52 pm ---Yes, but remember hello world examples are made for NEWBIES :). Teaching them a little won't hurt anyone.
--- End quote ---
When I was a C++ beginner, this main
--- Code: ---int main(int argc, char *argv[])
--- End code ---
always scared me :D.
Now a little less, but still... :D.
Michael
yop:
--- Quote from: rickg22 on December 14, 2005, 08:29:52 pm ---Yes, but remember hello world examples are made for NEWBIES :). Teaching them a little won't hurt anyone.
--- End quote ---
A typical new project at my work:
Fire up KDevelop.
New QMake project -> Hello world application
Nope Hello world is not for newbies, it's the beginning of everything ;)
bszente:
--- Quote from: Michael on December 14, 2005, 08:26:23 pm ---Personally, I prefer
--- Code: ---int main()
--- End code ---
when I do not need specific options
What is important is that the main must return type int.
--- End quote ---
Yes, you're right that only the int return type is important. However it's easier personally for me (and for the newbies) to delete the parameter list, than to re-type it (in case I need it). And for such console applications the command line parameters are frequently used...
What do you say about putting an "annoying" comment before the main... ? This way the newbies will not be scared, and this way they learn too... :)
--- Code: ---// You may delete the parameter list, if you don't use it
int main(int argc, char *argv[])
--- End code ---
For advanced users - remember: you always have the option to make your own template... I think those predefined hello world templates should target the newcomers. But of course all this subject is a matter of personal taste.
Michael:
--- Quote from: bszente on December 15, 2005, 08:57:50 am ---What do you say about putting an "annoying" comment before the main... ? This way the newbies will not be scared, and this way they learn too... :)
--- Code: ---// You may delete the parameter list, if you don't use it
int main(int argc, char *argv[])
--- End code ---
--- End quote ---
Yes, that could be a useful addition. May be:
--- Code: ---// If you do not use the parameter list, you can use instead:
// int main()
int main(int argc, char *argv[])
--- End code ---
Important it is to not forget the returned type. I have read in an article that a teacher used:
--- Code: ---main()
--- End code ---
Because it was easier to understand for the students. There was not the problem of returned type... :roll:. Na ja, could be. But this is not C++ or not ISO standard C++.
Michael
Navigation
[0] Message Index
[*] Previous page
Go to full version