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

Function computeValues

Examples/Modules/Chapter 16/Ex16_07A/Ex16_07A.cpp:24–39  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

22}
23
24double* computeValues(size_t howMany)
25{
26 double* values{ new double[howMany] };
27 try
28 {
29 for (size_t i {}; i < howMany; ++i)
30 values[i] = computeValue(i);
31 return values;
32 }
33 catch (const Trouble&)
34 {
35 std::cout << "I sense trouble... Freeing memory..." << std::endl;
36 delete[] values;
37 throw;
38 }
39}
40
41double computeValue(size_t x)
42{

Callers 1

mainFunction · 0.70

Calls 1

computeValueFunction · 0.70

Tested by

no test coverage detected