Object Oriented Concepts - Difference between generalization and realization




What is the difference between generalization and realization ?

Generalization connects a sub-class to a super-class. It’s another name for inheritance. Realization connects a class to an interface. It’s another name for implementation.

Generalization is equivalent to public inheritance in C++ or ‘extends’ in java. It implies inheritance of interface and implementation.

Realizes is equivalent to ‘implements’ in java. It represents conformance to an interface as opposed to inheriting anything.

So in C++ how are they distinguished?

I don’t bother distinguishing them in C++; there’s very little point. However, if you want to be very pedantic about it, the distinction is as follows:

Use ‘realizes’ any time you inherit from a class that has no member variables, and only pure virtual functions. Use ‘generalization’ for all other forms of inheritance.


Leave a Comment

You must be logged in to post a comment.