Re: The worst 'hello world' example ever written...

C

C

[Cross posted to comp.lang.c++ as an example of the worst
'hello world' example ever written in C++, please point out
any errors I have missed. (The original poster (The_Sage)
proposes this example is 100% correct, I submit it to the
experts for critique.)]

Not wrong, your specification is bad practice, and not the C++
idiom for the inclusion of C++ headers.
No it doesn't, since cout doesn't return anything.

The return from 'cout' is irrelevant; this is C++ not
functional programming.

gemini(300)$ cat sag.cc
#include <iostream.h>
void main(){ cout << "Hello, World!" }
gemini(301)$ g++ -Wall sag.cc
sag.cc: At global scope:
sag.cc:2: `main' must return `int'
sag.cc:2: return type for `main' changed to `int'
sag.cc: In function `int main(...)':
sag.cc:2: parse error before `}' token
gemini(302)$ g++ --version
3.0
No need to.

Yes there is, some systems will not print anything otherwise.
Do you really want the portability which is the only real
advantage of C++ in this application?
The "}" takes care of that last ";".

No it does not; this is C++ not Pascal. See the above gcc
error messages.
That's what the following is...

Are you (The_Sage) completely unable to admit even the
simplest error? We all make mistakes, but when 99% of the
people on the group are confronted with one they would just
say 'whoopsy daisy, this is what I ment...', but not you.
You could have just replied 'oops, typo' and would most
probably have been duely forgiven, but instead you constantly
paint yourself into a corner as more and more evidence
proving you are wrong comes to light, loosing all credability
in the process.

I have posted this across to 'comp.lang.c++' as the people
there know C++ much better than I. I am sure they will be
able to inform you of exactly which parts of the standard
you have broken.

C
2003/9/14

PS: I am unsure whether the C++ standard specifies the auto
generation of the 'return 0;' sequence on the main() procedure
and would appreciate clarification on this matter.
 
B

Buster Copley

C said:
[Cross posted to comp.lang.c++ as an example of the worst
'hello world' example ever written in C++, please point out
any errors I have missed. (The original poster (The_Sage)
proposes this example is 100% correct, I submit it to the
experts for critique.)]

Not wrong, your specification is bad practice, and not the C++
idiom for the inclusion of C++ headers.
http://www.parashift.com/c++-faq-lite/coding-standards.html#faq-27.4
No it doesn't, since cout doesn't return anything.

The return from 'cout' is irrelevant; this is C++ not
functional programming.

http://www.parashift.com/c++-faq-lite/newbie.html#faq-29.3

cout is not a function; the name of the function which is called here is
'operator <<', and its return type is 'ostream &' (or more precisely,
gemini(300)$ cat sag.cc
#include <iostream.h>
void main(){ cout << "Hello, World!" }
gemini(301)$ g++ -Wall sag.cc
sag.cc: At global scope:
sag.cc:2: `main' must return `int'
sag.cc:2: return type for `main' changed to `int'
sag.cc: In function `int main(...)':
sag.cc:2: parse error before `}' token
gemini(302)$ g++ --version
3.0

Not OK. Main always returns int and there is no 'implicit int' in C or
in C++.
Yes there is, some systems will not print anything otherwise.
Do you really want the portability which is the only real
advantage of C++ in this application?

The buffer will be flushed when the cout object is destroyed. A newline
might be nice though.
No it does not; this is C++ not Pascal. See the above gcc
error messages.

That's right, C++ is not Perl and you do need the semicolon.

Not really; that's just a closing brace. The return is implicit. main
implicitly returns 0 (EXIT_SUCCESS) when the closing brace is reached.

[snip]
PS: I am unsure whether the C++ standard specifies the auto
generation of the 'return 0;' sequence on the main() procedure
and would appreciate clarification on this matter.

Auto generation is a funny way of looking at it, but yes, the effect is
as if there were a 'return 0;' before the closing brace.

Here's one way of doing it correctly:

#include <iostream>
int main () { std::cout << "Hello, world!\n"; }

Questions? Comments? Suggestions?
Regards,
Buster.
 
W

White Wolf

C said:
[Cross posted to comp.lang.c++ as an example of the worst
'hello world' example ever written in C++, please point out
any errors I have missed. (The original poster (The_Sage)
proposes this example is 100% correct, I submit it to the
experts for critique.)]
[SNIP]

The guy is either a troll or a simpleton. Just ignore him.
 
K

Kevin Goodsell

C said:
[Cross posted to comp.lang.c++ as an example of the worst
'hello world' example ever written in C++, please point out
any errors I have missed. (The original poster (The_Sage)
proposes this example is 100% correct, I submit it to the
experts for critique.)]

We already had a thread making fun of this code earlier this week...

The main problems are:

* Non-standard (actually old, pre-standard) header. <iostream.h> no
longer exists in C++. The replacement is <iostream>

* Incorrect return type for main. The standard explicitly states that
main must return int. In fact, every document that has ever been
accepted as a standard for either C or C++ has required an 'int' return
type for main. Some allowed it to be implicit if the return type was
omitted. This is no longer allowed in either language.

* The output may never be seen. This is not a problem with flushing
(cout will be flushed when it is destroyed on program termination). It
is a problem with not properly terminating the line. A C++ program
should end it's output with a newline.

* Once the correct header is used, cout is placed in the std namespace,
therefore it's full name is std::cout. It can either be referred to
using this fully qualified name or the name can be brought into scope
using a 'using' statement.

* Missing semi-colon after the one and only statement in main().


(referring to said:
Not wrong, your specification is bad practice, and not the C++
idiom for the inclusion of C++ headers.

Clearly a fundamental misunderstanding of how the language works.
Yes there is, some systems will not print anything otherwise.

The buffer is flushed, but the output still may not be seen without a
newline.

Another fundamental misunderstanding about the language. Semi-colons
terminate C++ statements, they don't separate them. A semicolon after
the 'cout' statement is necessary.

The corrected code looks like this:

#include <iostream> // no .h
int main() // returns int
{ std::cout << "Hello, World!\n"; } // std::, newline, semicolon.

-Kevin
 
J

Josh Sebastian

In fact, every document that has ever been
accepted as a standard for either C or C++ has required an 'int' return
type for main.

<OT>
This is not true. In C, an implementation is required to accept a program
which defines main with an int return type, but it is
implementation-defined whether (and which) other return types are
acceptable.
* The output may never be seen. This is not a problem with flushing
(cout will be flushed when it is destroyed on program termination). It
is a problem with not properly terminating the line. A C++ program
should end it's output with a newline.

It's implementation-defined. From C99 draft n869, 7.19.2:

A text stream is an ordered sequence of characters composed into lines,
each line consisting of zero or more characters plus a terminating
new-line character. Whether the last line requires a terminating
new-line character is implementation-defined.

Josh
 
K

Kevin Goodsell

Josh said:
<OT>
This is not true. In C, an implementation is required to accept a program
which defines main with an int return type, but it is
implementation-defined whether (and which) other return types are
acceptable.
</OT>

Yeah, that's true. Kind of a technicality though... if you expect your
code to work on a standard compiler, you still have to use 'int' as
main's return type.
It's implementation-defined. From C99 draft n869, 7.19.2:

A text stream is an ordered sequence of characters composed into lines,
each line consisting of zero or more characters plus a terminating
new-line character. Whether the last line requires a terminating
new-line character is implementation-defined.

Josh

2 things: 1, I'm not sure why you are referencing C99 for a C++
discussion - it may or may not be applicable. 2, that wording might be
intended as a warning not to count on the last line of your *input*
being properly terminated. I wonder if there's a more explicit statement
about terminating the last line of the standard output - I think I've
heard that there is.

I'm sure it's either undefined or implementation defined, though. In any
case, it's best to terminate output with a newline.

-Kevin
 
J

Josh Sebastian

Josh Sebastian wrote:

2 things: 1, I'm not sure why you are referencing C99 for a C++
discussion - it may or may not be applicable.

Section 7 of C90, with a few exceptions, is normative in C++98. I don't
have a copy of C90, but I assume (I know -- dangerous) that the wording is
similar.
2, that wording might be
intended as a warning not to count on the last line of your *input*
being properly terminated. I wonder if there's a more explicit statement
about terminating the last line of the standard output - I think I've
heard that there is.

I couldn't find one, but that doesn't mean it isn't there.
I'm sure it's either undefined or implementation defined, though. In any
case, it's best to terminate output with a newline.

True.

Josh
 
T

The_Sage

Reply to article by: (e-mail address removed) (C)
Date written: 14 Sep 2003 05:42:24 -0700
MsgID:<[email protected]>
[Cross posted to comp.lang.c++ as an example of the worst
'hello world' example ever written in C++, please point out
any errors I have missed. (The original poster (The_Sage)
proposes this example is 100% correct, I submit it to the
experts for critique.)]

Yes, and they whipped your ass too.

The Sage

=============================================================
My Home Page : http://members.cox.net/the.sage

"The men that American people admire most extravagantly are
most daring liars; the men they detest the most violently are
those who try to tell them the truth" -- H. L. Mencken
=============================================================
 
T

The_Sage

Reply to article by: Kevin Goodsell said:
Date written: Sun, 14 Sep 2003 20:01:54 GMT
MsgID:<[email protected]>
[Cross posted to comp.lang.c++ as an example of the worst
'hello world' example ever written in C++, please point out
any errors I have missed. (The original poster (The_Sage)
proposes this example is 100% correct, I submit it to the
experts for critique.)]
We already had a thread making fun of this code earlier this week...

As we will see, the laugh is on you...
The main problems are:
* Non-standard (actually old, pre-standard) header. <iostream.h> no
longer exists in C++. The replacement is <iostream>

It isn't non-standard, is just isn't specified in the standard that way. It is
on your hard drive as "iostream.h" and you can use it both ways, just one way is
standard and the other is not.
* Incorrect return type for main. The standard explicitly states that
main must return int. In fact, every document that has ever been
accepted as a standard for either C or C++ has required an 'int' return
type for main. Some allowed it to be implicit if the return type was
omitted. This is no longer allowed in either language.

The C standard (ISO/IEC 9899:1999) does not require main() to return anything
although the C++ standard does. But ISO C++ Standard (ISO/IEC 14882:1998)
specifically requires main to return int although you *can* use void main() in
IBM, WATCOM, or MS C++ (as well as other) ISO compliant compilers.
http://homepages.tesco.net/~J.deBoynePollard/FGA/legality-of-void-main.html
* The output may never be seen. This is not a problem with flushing
(cout will be flushed when it is destroyed on program termination). It
is a problem with not properly terminating the line. A C++ program
should end it's output with a newline.

Obviously you are an armchair programmer since you are merely guessing. All that
will happen is this...

C:\>Hello
Hello World
C:\

Instead of...

C:\>Hello
Hello World

C:\

No guessing needed! Funny how the real world works like that, eh?
* Once the correct header is used, cout is placed in the std namespace,
therefore it's full name is std::cout. It can either be referred to
using this fully qualified name or the name can be brought into scope
using a 'using' statement.

Or you can set it in some compilers to default to namespaces by default...which
most do.
* Missing semi-colon after the one and only statement in main().

That's because it isn't required in all cases. The bracket takes care of that
one special case where it isn't required.
(referring to <iostream.h>
<iostream.h> does not exist in standard C++. It's as simple as that.

Yes it does. Just do a file search for it on your computer (presuming you have a
ISO compliant C++ compiler installed on it).
Clearly a fundamental misunderstanding of how the language works.

Oh yes, "clearly". Not even close. Haha! You are so full of shit.

The Sage

=============================================================
My Home Page : http://members.cox.net/the.sage

"The men that American people admire most extravagantly are
most daring liars; the men they detest the most violently are
those who try to tell them the truth" -- H. L. Mencken
=============================================================
 
K

Kevin Goodsell

The_Sage said:
It isn't non-standard, is just isn't specified in the standard that way. It is
on your hard drive as "iostream.h" and you can use it both ways, just one way is
standard and the other is not.

My hard drive does not define what is and is not standard. Neither does
yours. <iostream.h> is not standard. Even when it is supplied with a
The C standard (ISO/IEC 9899:1999) does not require main() to return anything

A technicality. You still can't use 'void' if you expect your code to
compile on a standard compliant compiler.
although the C++ standard does.

Yes, it does. And you used void anyway. Therefore you were wrong.
But ISO C++ Standard (ISO/IEC 14882:1998)
specifically requires main to return int although you *can* use void main() in
IBM, WATCOM, or MS C++ (as well as other) ISO compliant compilers.

Are you sure? The lack of a compiler error does not make it correct. The
standard does not require a diagnostic for an incorrect return type for
main.

Wow, you can use a search engine.
Obviously you are an armchair programmer since you are merely guessing. All that
will happen is this...

C:\>Hello
Hello World
C:\

Instead of...

C:\>Hello
Hello World

C:\

No guessing needed! Funny how the real world works like that, eh?

Yeah, funny. There are any number of compilers/systems out there that
won't display this output. We've seen several posts here where somebody
said "My hello world program isn't working" and the problem was actually
that they failed to properly terminate the output. It seems you are the
one that's guessing, based on very limited experience.
Or you can set it in some compilers to default to namespaces by default...which
most do.

That sentence doesn't even make sense.

A standard-compliant compiler must issue a diagnostic for code that
fails to properly qualify names, or bring them into scope with a 'using'
statement.
That's because it isn't required in all cases.

It is in this case.
The bracket takes care of that
one special case where it isn't required.

I don't know what this means, but the bracket has nothing to do with
your missing semicolon. Though you may be able to find (broken)
compilers that allow 'void main' and no namespaces, I doubt you can find
any compiler that will accept the missing semicolon.
Yes it does. Just do a file search for it on your computer (presuming you have a
ISO compliant C++ compiler installed on it).

Again, what's on my computer has nothing to do with what is standard.
Oh yes, "clearly". Not even close. Haha! You are so full of shit.

Everyone here knows which of us is full of shit.

-Kevin
 
G

Greg Schmidt

It isn't non-standard, is just isn't specified in the standard that way. It is
on your hard drive as "iostream.h" and you can use it both ways, just one way is
standard and the other is not.

Okay, so one way is not standard, but that doesn't make it non-standard?
What kind of logic is that?

The standard does not preclude a compiler manufacturer from including
extra non-standard header files with their distribution. An example you
might know would be windows.h Such inclusion does not make them
standard.
you *can* use void main() in
IBM, WATCOM, or MS C++ (as well as other) ISO compliant compilers.
http://homepages.tesco.net/~J.deBoynePollard/FGA/legality-of-void-main.html

This is what's known as a "non-standard extension". Just because IBM
and MS support it doesn't make it standard.
Obviously you are an armchair programmer since you are merely guessing. All that
will happen is this...

C:\>Hello
Hello World
C:\

Instead of...

C:\>Hello
Hello World

C:\

What's this C:\ thing? My prompt looks like this:
(gregs) $
Have you ever tried any UNIX compilers, or are you merely guessing that
they will exhibit similar properties to Windows compilers? Here's what
it might look like if I ran that same app here:

(gregs) $ hello
Hello World(gregs) $

or maybe like this:

(gregs) $ hello
(gregs) $

Here's something else it might look like:
(gregs) $ hello
Segmentation fault, core dumped.
(gregs) $
No guessing needed! Funny how the real world works like that, eh?

Funny how the portion of the real world with which you are familiar is
like that. Funny how you believe that the entire real world is the same
as your experiences. Funny how long it might take you to track down
this bug when you port to a compiler which you are not familiar with,
and which implements "implementation defined" behaviour differently from
what you expect. Well, funny for us; not so funny for the guy that pays
you for the time it takes you to debug your port. The guess involved is
the one where you guess that other compilers (including future versions
of compiler X) work just like compiler X.
Or you can set it in some compilers to default to namespaces by default...which
most do.

What does "default to namespaces by default" mean?
That's because it isn't required in all cases. The bracket takes care of that
one special case where it isn't required.

As others have said here, it is in fact required by the standard. If
your compiler doesn't require it, then that's another non-standard
extension that you would be well advised not to rely on.
Yes it does. Just do a file search for it on your computer (presuming you have a
ISO compliant C++ compiler installed on it).

Hey, I found a file on my computer called TheSageIsABigIdiot.wiffle.blat
I guess it must be a part of standard C++, since I have an ISO compliant
C++ compiler installed. What's that, you say the file wasn't put there
by installing the compiler? Okay then, how about this other file called
g++ which was installed with the compiler, is that part of standard C++?
Oh yes, "clearly". Not even close. Haha! You are so full of shit.

cout isn't a function, it's an object. Objects don't return anything,
only functions do. And, as pointed out elsewhere, the function in
question ("<<") does return something. And the original comment was
with respect to the return value of main, which has absolutely nothing
to do with the return value of "<<". Seems pretty clear to me that
whoever wrote the "No it doesn't" line has demonstrated a fundamental
misunderstanding of at least 3 facets of the language, all in a single
sentence. If you don't see this, then you are also suffering from the
same misunderstanding.
"The men that American people admire most extravagantly are
most daring liars; the men they detest the most violently are
those who try to tell them the truth" -- H. L. Mencken

A-ha! I understand now! Sage is trying to become someone that American
people admire most extravagantly! He is afraid that if he posts factual
information or agrees with obvious truths he will become most violently
detested. Let me assure you, Sage, Mr. Mencken was not referring to
technical newsgroups when he made that statement.
 
J

Jonathan Mcdougall

you embarass yourself everytime you open your mouth.
It isn't non-standard, is just isn't specified in the standard that way. It is
on your hard drive as "iostream.h" and you can use it both ways, just one way is
standard and the other is not.

We discuss standard C++ here. If you have some problems with a
specific implementation, please take the discussion to its dedicated
newgroup.
The C standard (ISO/IEC 9899:1999) does not require main() to return anything
although the C++ standard does.

In both standards, main() is required to return int. Please, try to
be informed before posting such false statements.
But ISO C++ Standard (ISO/IEC 14882:1998)
specifically requires main to return int although you *can* use void main() in
IBM, WATCOM, or MS C++ (as well as other) ISO compliant compilers.
http://homepages.tesco.net/~J.deBoynePollard/FGA/legality-of-void-main.html

This is not a standard behavior and this newsgroup only discusses
standard C++. If you have some problems with a specific
implementation, please take the discussion to its dedicated newgroup.
Obviously you are an armchair programmer since you are merely guessing. All that
will happen is this...

C:\>Hello
Hello World
C:\

Instead of...

C:\>Hello
Hello World

C:\

No guessing needed! Funny how the real world works like that, eh?

We do not discuss the real world, we discuss standard C++. On one of
the implementations I work on, nothing is displayed since there is no
screen.

Standard C++ does not force implementations to flush the buffer when
std::cout is destroyed. If you have some problems with a specific
implementation, please take the discussion to its dedicated newgroup.
Or you can set it in some compilers to default to namespaces by default...which
most do.

Implementation-defined behaviors are not discussed here. If you have
some problems with a specific implementation, please take the
discussion to its dedicated newgroup.
That's because it isn't required in all cases. The bracket takes care of that
one special case where it isn't required.

Wrong. Please try to get informed before posting such false
statements.
Yes it does. Just do a file search for it on your computer (presuming you have a
ISO compliant C++ compiler installed on it).

Minesweeper also exists on my computer, yet it is not standard C++.
Just because a header is shipped with a compiler does not mean it is
standard.
Oh yes, "clearly". Not even close. Haha! You are so full of shit.

Please try to respect other posters, as we try to respect you.


What point are you trying to make here? You definitly know you are
wrong. Either you are a troll or you have some serious problems with
your keyboard.


Jonathan
 
C

C

Buster Copley said:
C said:
[snip]

Not OK. Main always returns int and there is no 'implicit int' in C or
in C++.

My original post (on alt.lang.asm) had the quoted example
on contigious lines, it got a little split up in the reply.
You are, never the less, entirely correct in your assertion.

[snip]
Not really; that's just a closing brace. The return is implicit.
main implicitly returns 0 (EXIT_SUCCESS) when the closing brace
is reached.

I must admit to being rather surprised that a return with a value
can be implied, is this just for the main() procedure or does it
apply to all functions and if the latter, surely it would be good
practice to write the return anyway?

[snip]
Here's one way of doing it correctly:

#include <iostream>
int main () { std::cout << "Hello, world!\n"; }

Ah! My counter example was almost correct (I do not think it made
it to comp.lang.c++ : see alt.lang.asm if you are interested), not
bad for someone who has neither a C++ compiler (at the time of
writing) or any knowledge of the C++ standard. :)

Anyway I will probably take the time to learn C++ properly (no
need to ask the opinions of all at comp.lang.c++ -- I am sure you
all think that a good idea), to that end your FAQ is comming in
very handy. Thanks.

C
2003/9/15
 
C

C

[snip]
The guy is either a troll or a simpleton. Just ignore him.

I wish that where possible, the arguments he (TSag) posts to
alt.lang.asm are totally against assembly programming and
founded on misconceptions which have not been true for years.
Sadly his arguments have just enough of a veneer of accuracy
that they cannot be simply ignored and must be confronted
else non experts in the field may be mislead -- the results
of proving him wrong you have seen in this thread.

So troll, yes, probably, but turning a blind eye is not an
option if new programmers are to be pursuaded that learning
the assembly paradigm is a good idea. Thanks for the reply
anyway.

C
2003/9/15

PS: Hopefully he will either go and pester another group, or
preferably, quite down, learn the subject properly, and become
a helpful member of the group.

PPS: Sorry for swinging rather offtopic for comp.lang.c++,
an explaination seemed in order -- pop over to alt.lang.asm
to see what has been happening for the last few months for a
better picture. [Please direct any follow ups to this post
there.]
 
K

Kevin Goodsell

C said:
I must admit to being rather surprised that a return with a value
can be implied, is this just for the main() procedure or does it
apply to all functions and if the latter, surely it would be good
practice to write the return anyway?

It only applies to main. A similar rule was adopted into the C language
with the C99 major update.

-Kevin
 
R

Randall Hyde

Kevin Goodsell said:
Wow, you can use a search engine.

:)
Based on my experience, that's about *all* he can do.
You should see his "Software Engineering" arguments.
Cheers,
Randy Hyde
 
R

Randall Hyde

The_Sage said:
Reply to article by: (e-mail address removed) (C)
Date written: 14 Sep 2003 05:42:24 -0700
MsgID:<[email protected]>
[Cross posted to comp.lang.c++ as an example of the worst
'hello world' example ever written in C++, please point out
any errors I have missed. (The original poster (The_Sage)
proposes this example is 100% correct, I submit it to the
experts for critique.)]

Yes, and they whipped your ass too.


I think that this is reasonable proof that TS ignores reality.
There is a special name for people who ignore reality: insane.
I've avoided tagging TS with this label as I don't enjoy calling
people names like this, but now he's gone completely over the
edge.

As it is a complete waste of time to engage in conversation
with an insane person, it's time to expand my killfile.
Cheers,
Randy Hyde
 
T

The_Sage

Reply to article by: Kevin Goodsell said:
Date written: Mon, 15 Sep 2003 01:41:41 GMT
MsgID:<[email protected]>
My hard drive does not define what is and is not standard. Neither does
yours. <iostream.h> is not standard. Even when it is supplied with a
compiler it is probably not the same as <iostream>. Things have changed
since ARM C++.

Whether it is a standard or not, it is acceptable. IBM, MS, and Borland all
agree with my interpretation of the standard and not yours.
A technicality. You still can't use 'void' if you expect your code to
compile on a standard compliant compiler.

Then explain why it compiles on three standard compilers, ie -- IBM, MS, and
Borland?
Yes, it does. And you used void anyway. Therefore you were wrong.

All the standard says is that main() must return an integer, not that you must
use whatever it returns. If you don't care what main() returns, you can use void
to "discard" it. Again, IBM, MS, and Borland agree with my interpretation and
not yours.
Are you sure? The lack of a compiler error does not make it correct.

Nor does it make it incorrect. Try another logical fallacy.
The
standard does not require a diagnostic for an incorrect return type for
main.

Hence the reason it is perfectly acceptable to ignore what main() returns by
using void.
Wow, you can use a search engine.

Wow, and you can't refute a simple search engine article.
Yeah, funny. There are any number of compilers/systems out there that
won't display this output.

Name some then. Don't try IBM, MS, or Borland, as they work.
That sentence doesn't even make sense.

That's your problem.
A standard-compliant compiler must issue a diagnostic for code that
fails to properly qualify names, or bring them into scope with a 'using'
statement.

You are just full of one excuse after another. No diagnostic is *required*
because it isn't *mandatory* that you use an int. You can ignore the value
returned if you don't need it, and still be compliant. Duh!
It is in this case.

Just because you say so, eh? Haha! Get a clue man before posting a reply on a
topic you known nothing about next time...please?

The Sage

=============================================================
My Home Page : http://members.cox.net/the.sage

"The men that American people admire most extravagantly are
most daring liars; the men they detest the most violently are
those who try to tell them the truth" -- H. L. Mencken
=============================================================
 
J

Jonathan Mcdougall

<snipped everything>

PLEASE! Know that every single post is kept on at least hundreds of
archive sites. People are using these resources for learning or
understanding. You are misinforming people.

I do not know what you are trying to prove, but please stop. Continue
that discussion privatly or stop. And this applies to everybody here.

It has lasted long enough.

Jonathan
 
J

Josh Sebastian

Whether it is a standard or not, it is acceptable. IBM, MS, and Borland all
agree with my interpretation of the standard and not yours.

You have not "interpreted" the standard, you have chosen to ignore
it. Those compilers also compile C code. That doesn't mean that valid C is
always valid C++. Your logic is faulty.

The reason it works is because they didn't want to break old code. K&R C
is no longer valid C, and ARM C++ is no longer valid C++. Compilers still
support those outdated dialects for pragmatic reasons.
All the standard says is that main() must return an integer,

No, that's not what it says. It says, "the return type of main must be
int". You defined main with a return type of void. That makes you wrong.
Nor does it make it incorrect.

Your logical fallacy merely invalidates your argument. The wording of
the standard makes the code incorrect.
Wow, and you can't refute a simple search engine article.

The article to which you linked doesn't need to be refuted: it is 100%
correct. Perhaps you should read it. In case you are too lazy to click on
your own links, here's what it says, in bold, at the top:

"void main() is not legal in C++"

It then goes on to discuss why it is (sometimes) legal in C. But we
weren't talking about C -- we were talking about C++.
Name some then. Don't try IBM, MS, or Borland, as they work.

Actually, it doesn't always work on Borland. The thing is, it /might/
work, but it's not /required/ to work. That's what "not correct" means. It
doesn't mean it will /always/ fail; it just means it won't always succeed.
That's your problem.

Your lack of command of the English language is no one's problem but your
own.
Just because you say so, eh? Haha!

What makes you think it's optional? Because you say so?

Josh
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

No members online now.

Forum statistics

Threads
473,763
Messages
2,569,562
Members
45,039
Latest member
CasimiraVa

Latest Threads

Top