when naming the constant in C++ program, WHY DOES IT IMPORTANT TO NAME FOR EXAMPLE INCHES_PER_FOOT ?

Recommended Answers

All 3 Replies

As opposed to what? Do you mean all in caps with underscores as a naming convention? What else would you name it?

Further to @Dani comments ...

Naming conventions like using ALL_CAPS
for global const values
helps the reader 'see'
that the value is a 'global const value'

Using descriptive names also helps the reader
follow the 'logic flow'
lends to 'self documentation as you go'

As unofficial rule - all C/C++ macros are written in all caps. Underscores simply helps to improve readability if constant consists from several words. It's possible to name a variable with underscores, but it's uncommon. So if you see all caps symbol with underscores in it - you can be pretty sure that it's a macro definition.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.