From the course: C++ Design Patterns: Structural

Unlock the full course today

Join today to access over 24,500 courses taught by industry experts.

What problem does the proxy solve?

What problem does the proxy solve? - C++ Tutorial

From the course: C++ Design Patterns: Structural

What problem does the proxy solve?

- [Instructor] I've created a demo to highlight an issue that might not be as obvious at first. The program loads a configuration file into memory, and prints out the contents. Let's take a look at the code. We've got an abstract base class config file, which has a pure virtual method guest settings that returns a vector of strings. This is the interface that concrete implementations of the config file class have to implement. The program defines a concrete implementation of the config file class called RealConfigFile. Now, this class has a constructor that takes a file name as an argument, opens the file, and reads its contents into a vector of strings. It also overrides the guest settings method to return the vector of strings that was read from the file. In the main function, I've created a real config file object with the file name of config.txt. The program uses a Boolean variable use settings to decide whether or not…

Contents