MCPcopy Create free account
hub / github.com/andreasfertig/programming-with-cpp20 / CreateCar

Function CreateCar

12.12-constexprAllocation1/main.cpp:23–32  ·  view source on GitHub ↗

#C A factory function to create a car

Source from the content-addressed store, hash-verified

21
22// #C A factory function to create a car
23constexpr Car* CreateCar(int i)
24{
25 switch(i) {
26 case 0: return new Mercedes{};
27 case 1: return new Toyota{};
28 case 2: return new Tesla{};
29 }
30
31 return nullptr;
32}
33
34constexpr int FastestCar()
35{

Callers 2

FastestCarFunction · 0.70
mainFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected