C++/따배C++ 08강 객체지향 기초
[C++/8.14] 클래스 안에 포함된 자료형 Nested types
polarcompass
2021. 10. 26. 21:01
728x90
#include <iostream>
using namespace std;
class Fruit
{
public:
enum FruitType
{
APPLE,
BANANA,
CHERRY,
};
class InnerClass
{
};
struct InnerStruct
{
};
private:
FruitType m_type;
public:
Fruit(FruitType type)
: m_type(type)
{
}
FruitType getType() { return m_type; }
};
int main()
{
Fruit apple(Fruit::APPLE);
if (apple.getType() == Fruit::APPLE)
{
cout << "Apple" << endl;
}
return 0;
}
728x90