MCPcopy Create free account
hub / github.com/ShiqiYu/CPP / main

Function main

week07/examples/function-pointer.cpp:9–18  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

7float (*norm_ptr)(float x, float y); //norm_ptr is a function pointer
8
9int main()
10{
11 norm_ptr = norm_l1; //Pointer norm_ptr is pointing to norm_l1
12 cout << "L1 norm of (-3, 4) = " << norm_ptr(-3.0f, 4.0f) << endl;
13
14 norm_ptr = &norm_l2; //Pointer norm_ptr is pointing to norm_l2
15 cout << "L2 norm of (-3, 4) = " << (*norm_ptr)(-3.0f, 4.0f) << endl;
16
17 return 0;
18}
19
20float norm_l1(float x, float y)
21{

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected