__Gcd (A, B) built-in function in C ++

Recently, I find out about a special function in C ++: __gcd(A,B) . this will return the greatest common factor of A and B.

 #include<iostream> #include<algorithm> using namespace std; main() { cout<<__gcd(10,40); //op: 10 } 

Is there any special reason to start defining a function with 2 underscores?

It can be as simple as gcd(A,B) , like other STL functions.

+5
source share
1 answer

Names starting with two underscores are reserved for implementation, which means that you are not allowed to define such names in your code, and there is no standard guarantee what these names mean, if they exist. However, the supplier may want to document some of these names, in which case you can use them with the product for which the supplier documents them.

+9
source

All Articles