This question already has answers here:
How does the Comma Operator work
(9 answers)
Closed 4 years ago.
I was practicing practicing some programming and by mistake wrote the following line of code :
int a,b;
cin>>a,b;
Can anybody explain what the comma does here and why doesn't the compiler show any error.
It means that the whole expression has the value b.
But because b is not initialised the behaviour of your code is undefined!
Modern compilers can warm you of this.
Related
This question already has answers here:
'colon' and 'auto' in for loop c++? need some help understanding the syntax
(3 answers)
Closed 7 months ago.
this is a quick question, Im translating a program that's in C++ to C, and I saw this line of code,
for (int v : adj[u]) {
referenced in this article: link
and I am not really sure what it does. I tried googling it and got results for range based for loops in C++, but cannot find anything that has this exact syntax and what it means. Help would be much appreciated.
It's a very simple for loop that iterates over the elements of adj[u], going 1 by 1.
This question already has answers here:
What's the difference between parentheses and braces in c++ when constructing objects
(1 answer)
what is aggregate initialization
(2 answers)
Closed 9 months ago.
From boost libraries, I found this example
I marked a line with a red arrow, indicating the notation that is confusing me.
Is this special to boost or is this some sort of anonymous function syntax? I wasn't aware that C++ or C had such notation. I only kind of recognize it from python and java experience.
This question already has answers here:
Integer literal with single quotes? [duplicate]
(2 answers)
Is there a way to write a large number in C++ source code with spaces to make it more readable? [duplicate]
(6 answers)
Closed 2 years ago.
I recently came across the following C++ code snippet:
int Mod = 998'244'353;
I was intrigued by the use of single quotes in this number.
Could someone elaborate on what this gets interpreted as and why is it accepted?
Also has this formatting always been there in c++?
This question already has answers here:
Using :: (scope resolution operator) in C++
(5 answers)
When do I use a dot, arrow, or double colon to refer to members of a class in C++?
(4 answers)
Closed 2 years ago.
I've started learning Classes in C++ and have come across this :: operator. I have no idea what it means and how/when to use it. It was in every piece of C++ code I'd ever seen. The tutorial I watched didn't explain what it is. Could anyone explain?
This question already has answers here:
Correct way to work with vector of arrays
(4 answers)
Closed 5 years ago.
Is vector<int[3]> a; valid C++ ?
Can this cause problems?
I tried just now...
It can't be compiled successfully on VS.
But if I only code vector<int[3]> a;, and don't use this vector, it can be compiled successfully.