Delphi Programming Forum
C++Builder  |  Delphi  |  FireMonkey  |  C/C++  |  Free Pascal  |  Firebird
볼랜드포럼 BorlandForum
 경고! 게시물 작성자의 사전 허락없는 메일주소 추출행위 절대 금지
델파이 포럼
Q & A
FAQ
팁&트릭
강좌/문서
자료실
컴포넌트/라이브러리
FreePascal/Lazarus
볼랜드포럼 홈
헤드라인 뉴스
IT 뉴스
공지사항
자유게시판
해피 브레이크
공동 프로젝트
구인/구직
회원 장터
건의사항
운영진 게시판
회원 메뉴
북마크
델마당
볼랜드포럼 광고 모집

델파이 Q&A
Delphi Programming Q&A
[10889] Re:입력 받은 function명을 실행할려면?
BloodWolf [cyberpd] 1270 읽음    2006-09-06 09:33
//---------------------------------------------------------------------------
#include <iostream>
#include <string>
#include <map>
#pragma hdrstop

typedef void (*FUNC_PTR)(void);
typedef std::map<std::string,FUNC_PTR> FUNC_MAP;

void foo(void)
{
    std::cout << "call function 'foo'" << std::endl;
}
//---------------------------------------------------------------------------

void bar(void)
{
    std::cout << "call function 'bar'" << std::endl;
}
//---------------------------------------------------------------------------

#pragma argsused
int main(int argc, char* argv[])
{
    FUNC_MAP func_map;
    func_map["foo"]=&foo;
    func_map["bar"]=&bar;

    std::string input;
    std::cout << "input function name: ";
    std::cin >> input;
   
    FUNC_MAP::iterator iterator=func_map.find(input);
    if(iterator!=func_map.end())
    {
        (iterator->second)();
    } else
    {
        std::cout << "can't find function '" << input << "'" << std::endl;
    }

    return 0;
}
//---------------------------------------------------------------------------

+ -

관련 글 리스트
10875 입력 받은 function명을 실행할려면? 임민우 1286 2006/09/04
10889     Re:입력 받은 function명을 실행할려면? BloodWolf 1270 2006/09/06
10890         Re:Re:너무 감사해요^^ 근데, 델파이코드로 안될까요? ;; 임민우 1422 2006/09/06
Google
Copyright © 1999-2015, borlandforum.com. All right reserved.