MCPcopy Create free account
hub / github.com/Apress/design-patterns-in-modern-cpp / main

Function main

Structural/NullObject/nullobject.cpp:94–115  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

92};
93
94int main()
95{
96 //auto logger = make_shared<ConsoleLogger>();
97
98 struct NullLogger : Logger
99 {
100 void info(const string& s) override {}
101 void warn(const string& s) override {}
102 };
103
104 // this will crash
105 shared_ptr<Logger> empty_logger;
106 auto logger = make_shared<NullLogger>();
107 BankAccount account{ "primary account", 1000 };
108
109 account.deposit(2000);
110 account.withdraw(2500);
111 account.withdraw(1000);
112
113 getchar();
114 return 0;
115}

Callers

nothing calls this directly

Calls 2

depositMethod · 0.45
withdrawMethod · 0.45

Tested by

no test coverage detected