O'Reilly logo

Mastering C++ Programming by Jeganathan Swaminathan

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Interface segregation

Interface segregation design principle recommends modeling many small interfaces for a specific purpose, as opposed to modeling one bigger interface that represents many things. In the case of C++, an abstract class with pure virtual functions can be thought of as an interface.

Let's take a simple example to understand interface segregation:

#include <iostream>#include <string>using namespace std;class IEmployee {      public:          virtual string getDoor() = 0;          virtual string getStreet() = 0;          virtual string getCity() = 0;          virtual string getPinCode() = 0;          virtual string getState() = 0;          virtual string getCountry() = 0;          virtual string getName() = 0;          virtual string getTitle() = 0;          virtual string getCountryDialCode() = 0; virtual string ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required