0

i would like to generate an enum with one element set to inifite. I know about the limits library, but it seems this can only be used for specific datatypes. Yet i would like to use it in enum:

enum Speedlimits{ schoolarea = 30; normalarea = 50; highway = inifite; }; 

Any suggestions?

2
  • 1
    Why do you want to set it to infinite? Commented May 27, 2018 at 14:12
  • 299792458 m/s ... not only a good idea, it's the law. Commented May 27, 2018 at 14:59

1 Answer 1

4

C++ has no notion of infinite (well, at least not in enum context - in math context there's std::numeric_limits::infinity). You'll have to settle for setting the value of highway to some magic number (like -42 or whatever won't be normally used) and then treat that number as meaning "infinite" in your client code.. Or maybe find a way to represent things where you don't need infinite.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.