Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

A space before function call in c++

Is the following code allowed in c++? a. foo() (note the space before "foo")

I would assume not, but the compiler doesn't complain.

like image 312
Rivka Avatar asked Dec 01 '25 08:12

Rivka


1 Answers

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.

like image 188
Andreas Fester Avatar answered Dec 03 '25 00:12

Andreas Fester



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!