예전 자유 게시판
자료구조와 알고리즘
나소주 2004-06-14 16:06
게임프로그래머를 위한 자료구조와 알고리즘 서적 내용 중 12장 이진트리 부분 중template <class DataType>
void Preorder( BinaryTree<DataType>* p_node,
void (*p_process)(BinaryTree<DataType>*) )
{
// if the node exists
if( p_node )
{
// process the current node
p_process( p_node );
// process the left child
if( p_node->m_left )
Preorder( p_node->m_left );
// process the right node
if( p_node->m_right )
Preorder( p_node->m_right );
}
}
선행 처리부분에 있는 함수 포인터가 이해가 되지 않는군요 제가 워낙 초보라서
void Preorder( BinaryTree<DataType>* p_node,
void (*p_process)(BinaryTree<DataType>*) )
보면 매개변수가 두 개인데, Preorder를 호출할 경우에는 왜 매개변수가 하나이고 또한 p_process(p_node)가 의미하는 것이 이론상으로 알겠는데, 코드 상에서는 이해가 되지 않는군요
- 답글: