How to name variables and functions?

closed account (GzwqM4Gy)
Hi everyone!

I'm new here (and a C++ beginner), and by that I would like to ask a simple first question; when naming variables and functions, is it better to begin with a lowercase letter than a uppercase letter? - In C#, I've heard that it is better to name a variable with a lowercase letter in the beginning, like newCar.
There are many different naming conventions. Only you can tell which one to use based on your personal preference, what you are used to, etc. If you work in a team, do as the others do.

Personally I always start function and variable names with lower case letter. Upper case letters I use for types.
Last edited on
A good nameing convention is as follows

class MyClass

void MyClass::MyFunc();

MyClass myLocalVar;
myLocalVar.MyFunc();
Last edited on
I do it this way

1
2
3
4
5
6
7
class MyClass //etc

void MyClass::myFunc(int supah){}

MyClass MyLocalClass;
int supahSauce = 0;
MyLocalClass.myFunc(supahSauce);
Last edited on
closed account (GzwqM4Gy)
Thanks a lot! :)
closed account (zb0S216C)
Beware! Identifiers that contain 2 consecutive underscores are reserved for the implementation, and identifiers that end in "_t" are reserved for Unix implementations. In addition, identifiers that begin with a single underscore are reserved for library implementations.

Wazzak
Topic archived. No new replies allowed.