Languages such as Java explicitly use the interface keyword to denote interfaces. Having used Java, the concept seems useful enough to me to justify a keyword to enforce the concept.
Of course one can use a pure virtual class and label it as an interface. However, this keyword seems to be so useful and differentiated from a pure virtual class as to be useful. Perhaps it is being included in C++ 0x?
It is an object-driven language. C is a Procedural Oriented language. It does not support object-oriented programming (OOP) features such as polymorphism, encapsulation, and inheritance programming.
Object-Oriented Programming in C Although the fundamental OOP concepts have been traditionally associated with object-oriented languages, such as Smalltalk, C++, or Java, you can implement them in almost any programming language including portable, standard-compliant C (ISO-C90 Standard).
Object-oriented programming (OOP) is a style of programming characterized by the identification of classes of objects closely linked with the methods (functions) with which they are associated. It also includes ideas of inheritance of attributes and methods.
These include: design patterns, abstraction, encapsulation, modularity, polymorphism, and inheritance. When not to use OOP: Putting square pegs in round holes: Don't wrap everything in classes when they don't need to be. Sometimes there is no need and the extra overhead just makes your code slower and more complex.
Because C++ allows multiple inheritance, and because an interface is an abstract class which has all of it's members also abstract/virtual, C++ does not need it - a class can simply "extend" multiple other classes, any of which may be purely virtual (abstract).
Java and C#, on the other hand do not permit MI, since the designers of those languages felt that MI creates more problems than it solves. But it is still necessary for an object to "be" many things (the OOP is-a relationship), so interfaces provide a mechanism which allows an object to be many things, without inheriting multiple implementations - keeping the baby, but throwing out the bathwater.
It's redundant, since interfaces are represented by having every class member be pure virtual (=0).
Adding an "interface" keyword would add complexity to the implementation without adding any truly useful capability; it would duplicate existing functionality. As others have said, it's just a pure virtual class. Java and C# had to have 'interface' to get a piece of what C++ already had. Philosophically, C++ is designed to enable programmers to write good software, not to prevent programmers from writing bad software. In my experience, the hoopla against MI is way overblown. Idiots misused it, like they misuse everything, and instead of blaming the idiots for being idiots, people blamed the tool.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With