8.14 클래스 안에 포함된 자료형 nested types
#include <iostream>
class Fruit
{
public:
enum class FruitType
{
APPLE,BANANA,CHERRY,
};
private:
FruitType m_type;
public:
Fruit(FruitType type) : m_type(type);
FruitType getType() { return m_type; }
}
int main()
{
Fruit apple(Fruit::FruitType::APPLE);
if (apple.getType == Fruit::FruitType::APPLE)
{
std::cout << "Apple" << "\n";
}
return 0;
}