I not very familiar with C++, have some issues with the multiple assignments
int a = 0, b = 0; works
int i; double d; char c; c = i = d = 42; also works but why this does not works.
int a = 4, float b = 4.5, bool ab = TRUE; This is to do with the allowed syntax. The format is, in very high-level terms, roughly:
type varName [ = expr ][, varName [ = expr ] ]?; Where there is no allowance at all for another type to be introduced mid-stream.
In practice declaring multiple variables per line can lead to a lot of ambiguity and confusion.
Quick quiz: What is the initial value of a? What type is b?
int* a, b = 0; If you guessed a was a NULL pointer and b was int* you'd be wrong. This is why it's often preferable to spell it out long-form so there's absolute clarity:
int* a; int b = 0;
boolshould betrue, notTRUE.int a = 4; float b = 4.5; bool ab = true; // in one lineworks.c = i = d = 42;is UB" no, this is well defined. "What if you doc = i = d = 55555" yes, that's UB if it causes a signed overflow. For unsigned wrap around it's still well defined.charcan be unsigned or signed. It implementation defined.