[42Seoul] CPP Module 01 - ex05

수빈·2022년 1월 11일
0

42CPP

목록 보기
10/11
post-thumbnail

포인터를 선언하고 거기에 private 함수들을 넣고, 다른 포인터에는 level 리스트를 넣었다.

void	(Karen::*funcs[4])(void) = {
	&Karen::debug,
	&Karen::info,
	&Karen::warning,
	&Karen::error
};
std::string levels[4] = {
	"DEBUG",
	"INFO",
	"WARNING",
	"ERROR"
};

반복문을 통해levels[i] == level일 때(this->*funcs[i])()를 실행하면 된다.

profile
42Seoul -soooh ~ 2022.04

0개의 댓글