MCPcopy Create free account
hub / github.com/Apress/beginning-cpp20 / hypotenuse

Function hypotenuse

Examples/Modules/Chapter 11/Ex11_08/Ex11_08.cpp:9–16  ·  view source on GitHub ↗

Make names from the math namespace available locally */ Note: text uses hypot(), but this causes ambiguities with hypot() function of with Visual Studio

Source from the content-addressed store, hash-verified

7// Note: text uses hypot(), but this causes ambiguities with hypot()
8// function of <cmath> with Visual Studio
9auto hypotenuse(const auto& x, const auto& y)
10{
11 using namespace math;
12 // Or:
13 // using math::square;
14 // using math::sqrt; /* Same as, of course: using std::sqrt; */
15 return sqrt(square(x) + square(y));
16}
17
18int main()
19{

Callers 1

mainFunction · 0.85

Calls 1

squareFunction · 0.50

Tested by

no test coverage detected