My attempt at value initialization is interpreted as a function declaration, and why doesn’t A a(()); solve it?

There is no enlightened answer, it’s just because it’s not defined as valid syntax by the C++ language… So it is so, by definition of the language.

If you do have an expression within then it is valid. For example:

 ((0));//compiles

Even simpler put: because (x) is a valid C++ expression, while () is not.

To learn more about how languages are defined, and how compilers work, you should learn about Formal language theory or more specifically Context Free Grammars (CFG) and related material like finite state machines. If you are interested in that though the wikipedia pages won’t be enough, you’ll have to get a book.

Leave a Comment