What is the meaning of int (expr) in C ++?

When you look at some code from a friend project, I recently saw a syntax similar to this one.

#include <iostream>

int main(){
    std::cout<< int(32.5/5)  << std::endl;
}

When you run the above code, you get 6what is the expected value if use intfunctions like a cast.

However, I had never seen this syntax before, and I could not find the documentation for it on the Internet. I also did an experiment and noticed that this syntax is not valid in C.

Can someone explain the meaning of this syntax with documentation links?

+4
source share
1 answer

This is not a constructor call or a "function". There is no "int" function.

; .

, (int)(32.5/5) ( ).

, , C .

+9

All Articles