-1

I have a design question. I'm writing a function in c++ that checks how a user installed my code, so either "app store", "web", "dvd". What is the best way to encode these? I imagine I don't literally want to return the strings, so should I use a #define for the three options and make them 0x01, 0x02, 0x03, or should I use an enum? Or some other option?

Trevor Hickey
  • 36,288
  • 32
  • 162
  • 271
jcam77
  • 173
  • 2
  • 4
  • 17

1 Answers1

2

Re

, so should I use a #define for the three options

No.

Only use macros as a last resort.

You can use an enum, and that's far better than stringly typed code.

Cheers and hth. - Alf
  • 142,714
  • 15
  • 209
  • 331