Using enum inside types – Compiler warning C4482 C++

Yes, enums don’t create a new “namespace”, the values in the enum are directly available in the surrounding scope. So you get:

enum sample {
  SAMPLE_ONE = 1,
  SAMPLE_TWO = 2
};

int main() {
  std::cout << "one = " << SAMPLE_ONE << std::endl;
  return 0;
}

Leave a Comment