已知当前编译环境为64位GCC,int占4字节,float占4字节,typeid返回的类型名中int对应"i",float对应"f",char对应"c"。代码如下:
#include <iostream>
#include <typeinfo>
using namespace std;
int main() {
int a = 10;
char b = 'a'; // 字符'a'的ASCII值为97
float c = 1.5f;
cout << sizeof(a + b) << " " << typeid(b + c).name() << endl;
return 0;
}