Is c++ still in heavy use today?

Pages: 12
this is why I like C/C++

cause you can do stuff like these

1
2
int C;   //intentionaly uninitialized
int CC = C++ > C ? 0 : 1;


solve equation for CC.
closed account (Dy7SLyTq)
CC=0 doesnt it? because unless C is at max, (which its not) ++ will always make it greater
Java and Javascript have no relation. They are as said, two different languages. They both came out in 1995, but Java was developed by Sun Microsystems and Javascript was developed by Netscape. Javascript was influenced by Java, but outside of that the only other relation is the couple of paradigms they have in common.
CC=0 doesnt it? because unless C is at max, (which its not) ++ will always make it greater


It's undefined.

You can't read and write a variable in the same sequence point. There is no way to know if the 'C' is evaluated before the 'C++'.

It's a variation of the a++ + ++a problem.
Last edited on
CC=0 doesnt it?
I don't think so, Suffix ++ returns the original value before incrementing.

Edit: Ah, missed Disch's post, I'm going with that.
Last edited on
closed account (Dy7SLyTq)
sorry my mistake. i havent had to use ++ in a while where it mattered in which it was placed (so really only loop increments). and i thought it would be undefined, but when he said you could do that stuff i didnt question it

int C; //intentionaly uninitialized
int CC = C++ > C ? 0 : 1;

solve equation for CC.


Let's see (just for my clarification):
1
2
3
4
5
6
int C;
int CC;
if(C++ > C)
      CC = 0;
else
      CC = 1;

Error, wrong answer with possible segfault. We are using a comparison with whatever data is in the memory location for C which may not be the proper needed data.
Error, wrong answer with possible segfault


??? How would that ever segfault??
@firedraco


Error, wrong answer with possible segfault


??? How would that ever segfault??


From the C Standard

5 Certain object representations need not represent a value of the object type. If the stored value of an object has such a representation and is read by an lvalue expression that does not have character type, the behavior is undefined. If such a representation is produced by a side effect that modifies all or any part of the object by an lvalue expression that does not have character type, the behavior is undefined.50) Such a representation is called a trap representation.
your missing the point all of you, DTSCode, Ditch, vlad, firedraco, BHXSphere, and Easton.

the question is in the semantics.

which is better (>) language? C or C++ for the guy who started this conversation. Which should he concentrate on?
closed account (Dy7SLyTq)
no we arent. we know exactly what the point is, but the question has been answered
BHXSpecter, concerning your code, yes I imagine it might not pass compilation on the VC++ compiler, because it likes to initialize variables to values that have semantic meanings that will segment any unproper use, such as this incident. However, if my memory serves my correctly, the gcc compiler on Linux does not bother, so an uninitialized variable has REALL trash value and not initialized by compiler junk which I hate btw in the VC++ compilers
Concerning my code? My code is your code. Though, I've not heard of any implementation of the C++ standard that forced you to initialize it.

?: is the same as if..else
Topic archived. No new replies allowed.
Pages: 12