进行short和char和float与其他类型计算时,先变为int或double然后在变回来。而进行纵向的计算时,低层的数据会被默认转化为高层的数据。
数据类型的检测:
#include <iostream>
#include <typeinfo>
using namespace std;
main()
{
int a = 33;
double b = 333;
long int c = 3;
unsigned d = 3333;
b += a;
a *= b;
std::cout << typeid(c*d).name() << std::endl;
std::cout << typeid(a*c).name() << std::endl;
}