Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Stylistic choices

Name: Anonymous 2011-12-13 3:18

I tend to prefer to use namespaces filled with constants, rather than using enums in most cases. For example using

namespace Element {
const uint8_t No_Element = 0;
const uint8_t Air = 1;
const uint8_t Water = 2;
const uint8_t Earth = 3;
const uint8_t Fire = 4;
};


instead of


enum Element {
No_Element, Air, Water, Earth, Fire
};


Is this bad practice?

Name: Anonymous 2011-12-13 4:47

>>15

Except here's the thing...

Say I have a function where I only need the elements namespace and not the Attack_Damage namespace. I can

int8_t Damage_Multiplier(const uint8_t element) {
using namespace Elements;
// My code here, uninhibited by Elements::Fire shit
}


and outside, where I have to make the Elements and Attack_Damage namespaces play nicely, I can refer to them by Elements::Fire and Attack_Damage::Fire respectfully.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List