a + b - c * d
If the types of a, b, c, and d are int, long int, float, and double respectively, then the type of the expression is:
You can just ask your compiler.
#include <iostream>
#include <typeinfo>
int main()
{
int a;
long int b;
float c;
double d;
std::cout << typeid(a + b - c * d).name() << std::endl;
}
then the type of the expression is
The longest, floatiest type.
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.