![]() |
|
Welcome to the Computer Webmaster Gaming Console Graphics Forum forums. You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today! If you have any problems with the registration process or your account login, please contact contact us. |
| |||||||
| Software Programming Software programming talk, ask questions about computer software programming or help others |
![]() |
| | LinkBack | Thread Tools | Display Modes |
| | #1 | ||
| On Tue, 15 Jul 2003 20:50:36 -0700, Mario <tahomaoso@lvcm.com> wrote: > Make sure that's not all you're typing... > > #include <iostream.h> > int main() > { > cout<<"what ever you want to write"; > return 0; > } > The above should work, provided that you have set up your compiler > correctly. That's deprecated. The current ISO standard says, that all stdlib stuff is in a namespace called std. The above example should look like: #include <iostream> // note: without '.h' using namespace std; int main() { cout<<"Hello World"; return 0; } | |||
| Advertisements |
| | #2 | ||
| "Frithjof Engel" <frithjof@fms-engel.de> wrote in message news:bhbeth$ung3c$1@news.hansenet.net... > That's deprecated. The current ISO standard says, that all stdlib > stuff is in a namespace called std. The above example should look like: > > #include <iostream> // note: without '.h' > using namespace std; > > int main() > { > cout<<"Hello World"; > return 0; > } That's unnecessary; the return on main, if it is not actually being used, may be completely omitted. Here's a quote from "The C++ Programming Language" by Bjarne Stroustrup, the author of C++ language: "The int value returned by main(), if any, is the program's return value to "the syttem." If no value is returned, the system will received a value indication successful completion." [section 3.2, pp46] Thus the following is a valid version: #include <iostream> using namespace std; int main() { cout << "Hello, World" << endl; } | |||
| | #3 | ||
| In article <BRF%a.37716$2x.3841@rwcrnsc52.ops.asp.att.net>, "AngleWyrm" <no_spam_anglewyrm@hotmail.com> wrote: >"The int value returned by main(), if any, is the program's return value to > "the syttem." If no If that's the case, maybe your program should read: cout << "Don't disturb this groove!" << endl; :^) Alan | |||
| | #4 | ||
| "AngleWyrm" <no_spam_anglewyrm@hotmail.com> wrote in message news:BRF%a.37716$2x.3841@rwcrnsc52.ops.asp.att.net ... > "Frithjof Engel" <frithjof@fms-engel.de> wrote in message news:bhbeth$ung3c$1@news.hansenet.net... > > That's deprecated. The current ISO standard says, that all stdlib > > stuff is in a namespace called std. The above example should look like: > > > > #include <iostream> // note: without '.h' > > using namespace std; > > > > int main() > > { > > cout<<"Hello World"; > > return 0; > > } > > That's unnecessary; the return on main, if it is not actually being used, may be completely omitted. > Here's a quote from "The C++ Programming Language" by Bjarne Stroustrup, the author of C++ language: > "The int value returned by main(), if any, is the program's return value to "the syttem." If no > value is returned, the system will received a value indication successful completion." > [section 3.2, pp46] > > Thus the following is a valid version: > #include <iostream> > using namespace std; > int main() > { > cout << "Hello, World" << endl; > } This is the kind of ad-hoc hackery that I despise about C and C++. Here we have a procedure, that is declared as returning a value (specifically, an int), and there is no "return" statement anywhere in sight. This is, to a SANE language, a self-evident error on the programmer's part. My question: Is this a special case just for a procedure named "main", or is this a special case for any procedure with a signature "int XXX(void)" or "int XXX(unspecified)", or what? And observe, if the special case is only for procedure "main", what happens if we decide to change "main" to something else, to put a wrapper around it? Is it now erroneous, or do we just return garbage to the enclosing main()? | |||
| | #5 | ||
| "John R. Strohm" <strohm@airmail.net> wrote in message news:bhp6ru$qg4@library2.airnews.net... > "AngleWyrm" <no_spam_anglewyrm@hotmail.com> wrote in message > news:BRF%a.37716$2x.3841@rwcrnsc52.ops.asp.att.net ... > > "Frithjof Engel" <frithjof@fms-engel.de> wrote in message > news:bhbeth$ung3c$1@news.hansenet.net... > This is the kind of ad-hoc hackery that I despise about C and C++. > > Here we have a procedure, that is declared as returning a value > (specifically, an int), and there is no "return" statement anywhere in > sight. > > This is, to a SANE language, a self-evident error on the programmer's part. > > My question: Is this a special case just for a procedure named "main", or is > this a special case for any procedure with a signature "int XXX(void)" or > "int XXX(unspecified)", or what? Yes, this is a special case, specifically for the program entry point called "main". It may be true that not explicitly declaring a return could be construed as confusing, and therefore possibly bad programming practice. It might also be acceptable to say that it is a default that is almost never used. C++ has the marks of evolution within it's existance. For instance, the wchar_t is a rather strange way to name a basic variable type; it seems like it would have been more orthagonal to name it wchar, and leave it at that. | |||
| | #6 | ||
| AngleWyrm wrote: > "John R. Strohm" <strohm@airmail.net> wrote in message news:bhp6ru$qg4@library2.airnews.net... > > "AngleWyrm" <no_spam_anglewyrm@hotmail.com> wrote in message > > news:BRF%a.37716$2x.3841@rwcrnsc52.ops.asp.att.net ... > > > "Frithjof Engel" <frithjof@fms-engel.de> wrote in message > > news:bhbeth$ung3c$1@news.hansenet.net... > > This is the kind of ad-hoc hackery that I despise about C and C++. > > > > Here we have a procedure, that is declared as returning a value > > (specifically, an int), and there is no "return" statement anywhere in > > sight. > > > > This is, to a SANE language, a self-evident error on the programmer's part. > > > > My question: Is this a special case just for a procedure named "main", or is > > this a special case for any procedure with a signature "int XXX(void)" or > > "int XXX(unspecified)", or what? > > Yes, this is a special case, specifically for the program entry point called "main". It may be true > that not explicitly declaring a return could be construed as confusing, and therefore possibly bad > programming practice. It might also be acceptable to say that it is a default that is almost never > used. > > C++ has the marks of evolution within it's existance. For instance, the wchar_t is a rather strange > way to name a basic variable type; it seems like it would have been more orthagonal to name it > wchar, and leave it at that. I just try to ignore all this bizaare C++ crap and go on programming in C like I always have. Template ... whats that??? etc.. Of course since Im from the old days, I know how to write my own library routines from the bottom up (beside the programming I do wouldnt be helped much by all that generalized wigetry anyway...) I do use things like DirectX, but manage to avoid most of the C++ OOP gunk for the majority of the data crunching stuff (AI etc...) | |||
| Featured Websites | ||||
|
![]() |
| Tags: doing, right |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
| |
| Featured Websites | ||||
|