无题

来源:互联网 发布:串口收到的数据都是0 编辑:程序博客网 时间:2024/06/08 17:56
#include<list>
#include<map>
#include<string>
#include<iostream>
#include<string.h>
#include<new>
using namespace std;


typedef void (* PRINT)();
void printnme()
{
cout << "my name is cyc !" << endl;
}


void printyear()
{
cout << "my years old is 24!" << endl;
}


void printaddr()
{
cout << "my addr is fujian !" << endl;
}


enum{
NAME = 0,
YEAR=1,
ADDR=2,
};
PRINT Call[2] = {0}; 


/* ***************************************************************
如果觉得这样的全局变量占用太多空间,也可以修改成:


typedef struct {

    PRINT Callptr[2]
}InfoCallback,*InfoCallbackptr;




InfoCallback Call;  //然后在main函数里面这样:Call.Callptr[0] 
或者:
InfoCallbackptr Callptr;  //Callptr->Callptr[0] // 
*************************************************************** */
void init()
{
Call[0] = printnme;
Call[1] = printyear;
Call[2] = printaddr;
}


int main()
{
init();
Call[0]();
Call[2]();
    return 0;
}
0 0