▲ | xwolfi 6 days ago | |
An interface is a layer of translation between two things. In Object oriented programming, it's a contract between two encapsulated modules: you define how one should be used, without exposing internals, and the other will have only this contract to manipulate the module. Otherwise, for a graphical interface, it's a translation between what the machine can do and what the human can see. | ||
▲ | prewett 5 days ago | parent [-] | |
But in Object Oriented Programming an interface is also a class with only pure virtual methods, which is the interpretation that came most naturally to my detail-oriented mind. In this case it’s not a translation boundary, but rather a way to abstract away the details of which thing you’re actually talking to. Maybe the interviewer is okay with either answer, but I could easily see this question resulting in bzzt, you’re wrong if you happen to be thinking the way the interviewer isn’t. |