Any C++ newbie or wants to learn pls read

Started by
18 comments, last by TotalCoder 22 years, 4 months ago
I personally use void to indicate an empty parameter list in C++ too, I think it makes it more clear (maybe because I do a whole lot of C programming too?).
quote:Original post by TotalCoder
I''ll give it a try, do you have a link?

Bloodshed.net.
quote:Original post by TotalCoder
But I''ll look into Dev C++, does it have a color syntaxing IDE?

Yes. It''s a lot like MSVC.

[Resist Windows XP''s Invasive Production Activation Technology!]
Advertisement
quote:Original post by krez
you mean
int SomeFunc(void) { ... };  

right?
why not? i thought that was good form...

I dont recommend it - ergo its not recommended.



Fantastic doctrines (like Christianity or Islam or Marxism) require unanimity of belief. One dissenter casts doubt on the creed of millions. Thus the fear and hate; thus the torture chamber, the iron stake, the gallows, the labor camp, the psychiatric ward - Edward Abbey
--AnkhSVN - A Visual Studio .NET Addin for the Subversion version control system.[Project site] [IRC channel] [Blog]
Although this is probably a typo caused by haste, you need to return 0 now that you have the return type of main as int.

[Resist Windows XP''s Invasive Production Activation Technology!]
Null - nope. The standard explicitly states that if you exit main without returning a value, the effect will be that of returning 0.

(VC++ 6.0 doesnt work that way, tho)

Fantastic doctrines (like Christianity or Islam or Marxism) require unanimity of belief. One dissenter casts doubt on the creed of millions. Thus the fear and hate; thus the torture chamber, the iron stake, the gallows, the labor camp, the psychiatric ward - Edward Abbey
--AnkhSVN - A Visual Studio .NET Addin for the Subversion version control system.[Project site] [IRC channel] [Blog]
quote:Original post by Arild Fines
I dont recommend it - ergo its not recommended.

yes, i figured that out the first time you said "it''s not recommended"... but, what i meant to ask was: is there a reason for this, or is it a personal taste thing?
Sure there is a reason for it: I dont do it this way, and everybody should do things exactly the same way I do them.

Fantastic doctrines (like Christianity or Islam or Marxism) require unanimity of belief. One dissenter casts doubt on the creed of millions. Thus the fear and hate; thus the torture chamber, the iron stake, the gallows, the labor camp, the psychiatric ward - Edward Abbey
--AnkhSVN - A Visual Studio .NET Addin for the Subversion version control system.[Project site] [IRC channel] [Blog]
Thanks everyone for all your posts, critique, and recommendation. I appreciate everything that you have written. I have included everyone that has contributed to the tutorial in the additional credit section of the article, if any of you want your email or other names attached to it, let me know.

I''m working on the next tutorial which will combine input and outpout mostly cin and cout so that the reader can do some interactive stuff.



Sam
-----
TotalCoder
http://www.totalcoder.com
"Resources, tutorials, and articles for the novice, part-time, and hobbyist programmer"
Sam-----TotalCoderhttp://www.totalcoder.com"Resources, tutorials, and articles for the novice, part-time, and hobbyist programmer"
In your int main function, you should include "return 0;" before the closing brace.
Should there be a return 0 statement? Here is a quote from the Bjarne Style FAQ I found on the web.

quote:
In C++ main() need not contain an explicit return statement. In that case, the value returned is 0, meaning successful execution...


The return value is impled and 0 is returned.

Sam
-----
TotalCoder
http://www.totalcoder.com
"Resources, tutorials, and articles for the novice, part-time, and hobbyist programmer"
Sam-----TotalCoderhttp://www.totalcoder.com"Resources, tutorials, and articles for the novice, part-time, and hobbyist programmer"
Bjarne is absolutely correct, as I have pointed out earlier in this thread. Read the standard regarding the main function, section 3.6.2, I think(something like that, anyway - I dont have it here right now).
The main problem is that VC++ gives you a warning when exiting main without an explicit return statement, and since VC++ is the compiler ''everyone'' uses, people think this is they way its supposed to be.

Fantastic doctrines (like Christianity or Islam or Marxism or Microsoft-bashing) require unanimity of belief. One dissenter casts doubt on the creed of millions. Thus the fear and hate; thus the torture chamber, the iron stake, the gallows, the labor camp, the psychiatric ward - Edward Abbey
--AnkhSVN - A Visual Studio .NET Addin for the Subversion version control system.[Project site] [IRC channel] [Blog]

This topic is closed to new replies.

Advertisement