Translating c examples to c++ as I go along...

Started by
14 comments, last by daviangel 14 years, 10 months ago
Quote:Original post by phresnel
Quote:Original post by DraganO
Oh, come on guys...
Okay, I admit that my choice of words was a bit inauspicious.
What I meant to say is that a valid C program is also (at least most of the time) a valid C program

But, but, a valid C program is always a valid C program *ducks and covers*


*throws shoe and misses*
So, for the record: a valid C program is most of the time a valid C++ program

Well at least ToohrVyk got his proof now.^^
Advertisement
Quote:Original post by ToohrVyk
The essence of his post was "With a few minor changes, every valid C program is also a valid C++ program". Can you think of any major changes that would need to be applied to a C89 program (small syntax changes, and variable renaming, are minor) for it to be compiled by a standard C++ compiler?


That is a fair enough assertion, although I would point out that C89 is no longer standard C as it has been superseded by the C99 standard (and relevant amendments since then).
Quote:Original post by Cromulent
Quote:Original post by ToohrVyk
The essence of his post was "With a few minor changes, every valid C program is also a valid C++ program". Can you think of any major changes that would need to be applied to a C89 program (small syntax changes, and variable renaming, are minor) for it to be compiled by a standard C++ compiler?


That is a fair enough assertion, although I would point out that C89 is no longer standard C as it has been superseded by the C99 standard (and relevant amendments since then).


I am not sure whether there is a standard which specifies which of the standards is The Standard, quasi a standard standard. A valid C89 program is and always will be a valid C89 program. A valid C++2003 program will always be a valid C++2003 program, and it's not like it will magically become invalid by the rise of a new standard.
Quote:Original post by phresnel
Quote:Original post by Cromulent
Quote:Original post by ToohrVyk
The essence of his post was "With a few minor changes, every valid C program is also a valid C++ program". Can you think of any major changes that would need to be applied to a C89 program (small syntax changes, and variable renaming, are minor) for it to be compiled by a standard C++ compiler?


That is a fair enough assertion, although I would point out that C89 is no longer standard C as it has been superseded by the C99 standard (and relevant amendments since then).


I am not sure whether there is a standard which specifies which of the standards is The Standard, quasi a standard standard. A valid C89 program is and always will be a valid C89 program. A valid C++2003 program will always be a valid C++2003 program, and it's not like it will magically become invalid by the rise of a new standard.


By definition there can only ever be one standard, otherwise it wouldn't be a standard would it?
Quote:Original post by Cromulent
That is a fair enough assertion, although I would point out that C89 is no longer standard C as it has been superseded by the C99 standard (and relevant amendments since then).
Certainly—there is currently a C89 standard, a C99 standard, and the expression "standard C" refers to the C99 version by default (and a standard C89 program that does not respect C99 requirements cannot claim to be a standard C program anymore).

On the other hand, this discussion is not so much about standard C as it is about the version of the C language used in the "Game Programming all in one" book—which, from my recollections and the 2002 publishing date, seems to be C89.

Quote:Original post by ToohrVyk
Quote:Original post by Cromulent
That is a fair enough assertion, although I would point out that C89 is no longer standard C as it has been superseded by the C99 standard (and relevant amendments since then).
Certainly—there is currently a C89 standard, a C99 standard, and the expression "standard C" refers to the C99 version by default (and a standard C89 program that does not respect C99 requirements cannot claim to be a standard C program anymore).

On the other hand, this discussion is not so much about standard C as it is about the version of the C language used in the "Game Programming all in one" book—which, from my recollections and the 2002 publishing date, seems to be C89.

Is this is the J Harbour book? If so, yeah he uses outdated and convoluted C code throughout his books. In the second edition of the book he does make a partial attempt to migrate the code to C++ so you might want to check out that copy if you get lost.
In my experience and from what I've seen of others it seems easier to pick up C after C++ than the other way around so it shouldn't be too hard.
I have a C programmer friend right now trying to learn objective-c which is sort of like Apple tacking on the parts of C++ on of C that they like + some Smalltalk and he's totally lost since accessor,setter,getter,inheritance,objects, etc is all lost on him.
[size="2"]Don't talk about writing games, don't write design docs, don't spend your time on web boards. Sit in your house write 20 games when you complete them you will either want to do it the rest of your life or not * Andre Lamothe

This topic is closed to new replies.

Advertisement