Is the following code allowed in c++?
a. foo()
(note the space before "foo")
I would assume not, but the compiler doesn't complain.
Yes, it is valid C++ code:
From C++ Standard - ANSI ISO IEC 14882 2003.pdf, chapter 2.6:
There are five kinds of tokens: identifiers, keywords, literals, operators, and other separators. Blanks, horizontal and vertical tabs, newlines, formfeeds, and comments (collectively, “white space”), as described below, are ignored except as they serve to separate tokens.
The same chapter defines that a punctuator is also a token.
Chapter 2.12 Operators and punctuators defines that . is a punctuator.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With