Why unscoped enums' declaration compiles?
问题 In the Effective Modern C++ book of Scott Meyers it is mentioned that one of the main difference between unscoped and scoped enums(enum class) is that we can't forward declare the former (see Chapter 3, Item 10 - "Prefer scoped enums to unscoped enums" ). For example: enum Color; *// error!* enum class Color; *// fine* But I've written below mentioned small example and saw that it is not so. test.h #pragma once enum names; void print(names n); test.cpp #include "test.h" #include <iostream>