4 ms·
Huh, I don't think I've seen this constant naming convention before: const int kDaysInAWeek = 7;
by _delirium 16y ago
Huh, I don't think I've seen this constant naming convention before:
const int kDaysInAWeek = 7;
- uytghjhgf 16y agoAnd useful if the number of days in a week ever changes.
- jparise 16y agoWe used that C++ constant naming convention at EA, too. I like it because it nicely differentiates C++ typed constants from preprocessor constants and macros (which we SPELLED_THUSLY).
- _delirium 16y agoYeah, it appears it's actually quite common, and I must be one of the last people to be surprised by it. =] I've never been part of a major multi-person C++ project, though, so my stylistic conventions are a mixture of C conventions and the conventions used in the STL. I tend to SPELL_THUSLY even C++ typed constants, though I have also seen them PascalCased (but then, unless context makes it sufficiently clear, they can look like class names).
- Xuzz 16y agoIt's also used by Apple in all of their Cocoa and CoreFoundation code. An example from CoreFoundation would be their constant CFAllocator references: const CFAllocatorRef kCFAllocatorDefault; const CFAllocatorRef kCFAllocatorSystemDefault; const CFAllocatorRef kCFAllocatorMalloc; const CFAllocatorRef kCFAllocatorMallocZone; const CFAllocatorRef kCFAllocatorNull; const CFAllocatorRef kCFAllocatorUseContext;
- phatbyte 16y agoI'm actually learning C and I see it a lot in the book examples regarding macros(#define ....)