-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
  • 34,154
  • 27
  • 144
  • 256
jcam77
  • 163
  • 2
  • 4
  • 16

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
  • 138,963
  • 15
  • 198
  • 315