Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

C++ naming: read_input() vs. readInput()

Which naming convention is more preferable in C++? The underscore method or the camelCase method? I have coded in Java for a while and I am used to the camelCase naming conventions. Which one is more prevalent?

Also, while defining a class, is there any preferred ordering of private/public/protected variables/methods?
Are friends usually put in the end?
What about typedefs, do they come at the top of the class definition?

like image 766
user855 Avatar asked Nov 23 '09 19:11

user855


People also ask

Should I use CamelCase C++?

C++ code. Use CamelCase for all names. Start types (such as classes, structs, and typedefs) with a capital letter, other names (functions, variables) with a lowercase letter.

Should method names be capitalized C++?

Method NamingAll methods and functions should begin with a capital letter. The first letter of each word should also be capitalized. Special characters such as dashes and underscores are prohibited. The method name chosen should be descriptive of the method functionality.

Are function names case sensitive in C?

What is Meant by Case Sensitivity in C Language? The answer to the question is c language case sensitive is yes. The C language is case sensitive. This means that all language keywords, identifiers, function names, and other variables must be entered with consistent letter capitalization.

What is Pascal naming convention?

Pascal case -- or PascalCase -- is a programming naming convention where the first letter of each compound word in a variable is capitalized. The use of descriptive variable names is a software development best practice. However, modern programming languages do not allow variables names to include blank spaces.


1 Answers

I prefer to take the boost route, and match the standard library. That means lower_case_names. I like that my code reads consistent with respect to the STL.

like image 74
GManNickG Avatar answered Oct 20 '22 05:10

GManNickG