| 
1 
2 
3 
4 
5 
6 
7 
8 
9 
10 
11 
12 
13 
14 
15 
16 
17 
18 
19 
20 
21 
22 
23 
24 
25 
26 
27 
28 
29 
30 
31 
32 
33 
34 
35 
36 
37 
38 
39 
40 
41 | 
#include <stdio.h> 
class Robot 
{ 
public: 
    int Move(int type, int first, int second) 
    { 
        return (this->*m_func[type])(first, second); 
    } 
    int Plus(int first, int second) 
    { 
        return first + second; 
    } 
    int Minus(int first, int second) 
    { 
        return first - second; 
    } 
    static int (Robot:: * m_func[10])(int first, int second); 
}; 
int (Robot::* Robot::m_func[10])(int first, int second) = { 
        &Robot::Plus, 
        &Robot::Minus, 
}; 
int main() 
{ 
    Robot *pRobot = new Robot; 
    // 여기서는 Plus 함수를 호출하는 상황이 된다. 
    // print --> result : 3 
    int result = pRobot->Move(0, 2, 1); 
    printf("result: %d \n", result); 
    // 여기서는 Minus 함수를 호출하는 상황이 된다. 
    // print --> result : 3 
    result = pRobot->Move(1, 2, 1); 
    printf("result: %d \n", result); 
    return 0; 
} | cs | 
2016년 7월 1일 금요일
함수 포인터 참고..
피드 구독하기:
댓글 (Atom)
A*, JPS 길찾기 알고리즘 시뮬레이션 사이트
https://qiao.github.io/PathFinding.js/visual/ 길 찾기 알고리즘 시행 과정을 보여주는 사이트다. 링크 메모..
- 
메모리 풀을 사용하는 경우, 클래스의 생성자나 파괴자가 자동으로 호출되지 않는다. 그런 경우 외부에서 강제로 호출해줘야 하는 경우에 사용한다. // 개발 환경 VS2013 // tc_new 와 tc_delete 코드는 메모리풀 사용하는 코드라...
- 
예전에 게임 서버 포폴 만드는 공부에서 IOCP 구조로 만든 네트워크 스레드(n개)에서 받아들여온 패킷들을 Lock-Free Queue에 넣고, 게임 로직 스레드에서 꺼내다가 로직처리하도록 만들었었다. I have developed my game ...
 
댓글 없음:
댓글 쓰기