void和void *

void f(void) { // 参数void可以省略
    cout << "aa"<<endl;
}
int t = 22;
int *a = &t;
void *p;  // void *可以被赋值为其他类型
p = a;
cout << *(int *)p;  // 使用的时候必须转到那个类型

 

posted @ 2019-01-31 19:57  Jary霸  阅读(168)  评论(0编辑  收藏  举报