C++ / GCC - Why does this compile

c++, gcc

Solution

The first line provides a label `std:` followed by a null statement -- the semicolon.

The rest uses `cout << ...` and means you must have a `using namespace std;` or `using std::cout;` or something similar in effect.

The second uses an identifier `std` that isn't defined.

Problem

Coding away this evening (I realise it's Valentine's Day) and came across something strange... I have the following line: ``` std:;cout << freqs[summations[i]] / 1000 * 10 << std::endl; ``` This compiles. However, if I do this, it will not compile. ``` std;;cout << freqs[summations[i]] / 1000 * 10 << std::endl; ``` I don't have any strict properties on in my compile line. However, I wouldn't have thought GCC would allow this to be compiled and output. Why is this?

Original source

Related problems