查 multiset 时看到,作者写的代码:
#include <string>
#include <iostream>
#include <set>
using namespace std;
int main(){
int x;
scanf("%d",&x);
multiset<int>h; //建立一个multiset类型,变量名是h,h序列里面存的是int类型,初始h为空
while(x!=0){
h.insert(x); //将x插入h中
scanf("%d",&x);
}
while(!h.empty()){ // 序列非空 h.empty()==true时 表示h已经空了
__typeof(h.begin()) c=h.begin();
//c指向h序列中第一个元素的地址,第一个元素是最小的元素
printf("%d ",*c); //将地址c存的数据输出
h.erase(c); //从h序列中将c指向的元素删除
}
}
这个代码中的 __typeof 是什么意思?我只查到了typeof :“获取表达式数据类型,不计算表达式的值;即获取表达式返回值类型。”