Stupid question.
-
- Posts: 29
- Joined: Tue Jul 18, 2006 8:48 pm
- Contact:
Stupid question.
This is idiotic but it occurred to me the other day. C++ is an updated version of C right? So it's C incremented (C=C+1 // C++) to the next version? Is that where C++ came from or does it have some other significance?
Your question got me thinking about it also EEPROM7771. Looked it up in Wikipedia and I guess your assumption was correct: http://en.wikipedia.org/wiki/C++#The_name_.22C.2B.2B.22
It depends on the context.KamPutty wrote:My understanding is that "C++" does mean what you said, the next C increment.
Would ++C be different then C++?!
~Kam (^8*
When C++ occurrs in an expression, the value of C is used and then the variable is incremented by one.
When ++C occurs in an expression, C is incremented first and then the new value is used.
In Case 1, C will be incremented by 1 and then compared to MAX_VAL.
/* Case 1 */
if (++C > MAX_VAL)
/* condition true */ ;
else
/* condition false */
/* End Case 1 */
In Case 2, C will be compared to MAX_VAL unchanged, a note taken, and then C is incremented by 1.
/* Case 2 */
if (C++ > MAX_VAL)
/* condition true */ ;
else
/* condition false */
/* End Case 2 */
Case 1 can be coded as:
/* Alternative Case 1 */
C = C + 1;
if (C > MAX_VAL)
/* condition true */ ;
else
/* condition false */
/* End Alternative Case 1 */
Case 2 is equivalent to:
/* Alternative Case 2 */
bool CondFlag = C > MAX_VAL;
C = C + 1;
if (CondFlag)
/* condition true */ ;
else
/* condition false */;
/* End Alternative Case 2 */
All by its lonesome, C++; is equal to ++C;
See page 42, Section 2.8 of Kernighan & Ritchie's classic book, "The C Programming Language" Prentice-Hall, Inc., (c) 1978.
Hope this helps.
What's in a name?
Personally, I think <b>C++</b> is a very appropriate name. I intuitively associate <b>P</b> with <b>Pascal</b>, not C. When I see C++, I recognize the purpose of the ++ operator, and instantly know that C++ is based on C. Ironically, the reason I ran out and bought <b>Borland's C/C++ V1.0</b> system was because I wanted a C IDE. But it wasn't until I had advanced to <b>Microsoft Visual C/C++ V5.0</b> that I discovered the richness and shear power of C++.philba wrote:funny, the C language was derived from a language called B which was derived from a language called BCPL. So maybe C++ should have been called P.
I'm glad I learned C before C++. There are many things I prefer to do the old C way rather than the C++ way, like <i>printf</i> instead of the <i>overloaded <<</i> operator for output. Because of my C background, I am free to choose the approach that I like best, and the compiler doesn't care.
Hello again,
I havent followed the progress of C into C++ very well, but i too
have read that the name "C++" came from the fact that it was
derived from C and the fact that it has the operator "++" to
increment a variable by 1 as mentioned already.
I think it was originally called "New C" or "C with Classes".
It is interesting how the C name stuck for so long too, even into
C#. Seems there is something catchie about it, like it has a certain
extra appeal of some sort. On the other hand, Fortran sounds like some
sort of machine or something, and Pascal sounds like someones name,
and Cobol sounds like the name of a robot, ha ha.
BTW has anyone here tried the Euphoria language yet?
I am mentioning this because i use it all the time and it is
fairly easy to learn and it does not cost anything, even the
'full' version now, which went Public Domain a few months ago.
In short, it's like a subset of C only with 'sequences'. A sequence
being the main data type where you can store things similar
to arrays in C, only they are much more dynamic and variable
than in C. A drawback is that they are also slower when you use
very very large sequences, depending on how you use them.
The full version (now completely free and open source) allows you
to either run the include files directly (unlike C and C++ and other
languages) without compiling, or you can compile into an .exe
program and run on any machine that supports the platform you
created it for (Windows, Linux, freeBSD, etc.).
Very well worth looking into, especially if you want to create small
programs to do various tasks on your computer and dont feel like
buying the software to do this stuff.
Program examples (all Windows platforms with standard Windows GUIs):
Dictionary for English
Dictionary for Spanish
File rename program
Picture file viewer (jpg, bmp, gif, etc) (very fast too on Windows)
Advanced Engineering calculator for Windows
Currently there is a small group of users.
I havent followed the progress of C into C++ very well, but i too
have read that the name "C++" came from the fact that it was
derived from C and the fact that it has the operator "++" to
increment a variable by 1 as mentioned already.
I think it was originally called "New C" or "C with Classes".
It is interesting how the C name stuck for so long too, even into
C#. Seems there is something catchie about it, like it has a certain
extra appeal of some sort. On the other hand, Fortran sounds like some
sort of machine or something, and Pascal sounds like someones name,
and Cobol sounds like the name of a robot, ha ha.
BTW has anyone here tried the Euphoria language yet?
I am mentioning this because i use it all the time and it is
fairly easy to learn and it does not cost anything, even the
'full' version now, which went Public Domain a few months ago.
In short, it's like a subset of C only with 'sequences'. A sequence
being the main data type where you can store things similar
to arrays in C, only they are much more dynamic and variable
than in C. A drawback is that they are also slower when you use
very very large sequences, depending on how you use them.
The full version (now completely free and open source) allows you
to either run the include files directly (unlike C and C++ and other
languages) without compiling, or you can compile into an .exe
program and run on any machine that supports the platform you
created it for (Windows, Linux, freeBSD, etc.).
Very well worth looking into, especially if you want to create small
programs to do various tasks on your computer and dont feel like
buying the software to do this stuff.
Program examples (all Windows platforms with standard Windows GUIs):
Dictionary for English
Dictionary for Spanish
File rename program
Picture file viewer (jpg, bmp, gif, etc) (very fast too on Windows)
Advanced Engineering calculator for Windows
Currently there is a small group of users.
LEDs vs Bulbs, LEDs are winning.
Who is online
Users browsing this forum: No registered users and 62 guests