About the C++ category

Welcome to the C++ category. This is a space to ask any C++ questions, discuss exercises from the Exercism C++ track, or explore any other C+±related conversations!

1 Like

Hello, I was read in the Bible du programmeur C / C++ : 1500 astuces pour toutes les situations (C / C++ Programmer’s Bible : 1500 tips for all situations) book that the good habit to get into is to name variables (and functions) name_of_the_variable, and not nameOfTheVariable as written in the exercises. I agree with the book, although of course I can’t be sure.

Have a good day,
@eliotttak

Note : This book is verry old (1999 , we are in 2024 so the book is 25), so it is possible to the standards was evolved

C C++

Hi eliotttak,

in my experience “snake_case” and “lowerCamelCase” are the two most widely used styles for variable and function names in C++. As far as I can tell there’s no consensus in the community that one is “better” than the other, it depends on personal style and the established style of the project. Any mildly experienced programmer should be able to read and write both styles easily.
(Personally I prefer “snake_case”, too, but that’s just my own preference.)

I’d be hesitant to modify all the exercises that use “lowerCamelCase” for variable and function names, I think that’s too much effort for a stylistic change that’s not objectively better.

BTW: Learning C from old books is fine, the language has not much changed since 1999. But for C++ it’s different: C++11 (released in 2011) brought some major changes like move semantics and lambda expressions. I do not recommend learning from books that do not incorporate these features, they will not teach “modern C++”.

Happy programming! Matthias

1 Like