Relative Content

Tag Archive for abstract-class

Is there a different usage rationale for abstract classes/interfaces in C++ and Java

According to Herb Sutter one should prefer abstract interfaces (all pure virtual functions) to abstract classes in C++ to decouple the implementation as far as possible. While I personally find this rule very useful, I have recently joined a team with many Java programmers and in the Java code this guideline does not seem to exist. Functions and their implementations are very frequently located in abstract classes.
So did I get Herb Sutter all wrong even for C++ or is there a general difference in the usage of abstract functions in C++ compared to Java. Are abstract classes with implementation code more sensible in Java than in C++ and if yes why ?

What are the differences between abstract classes, interfaces, and when to use them

Recently I have started to wrap my head around OOP, and I am now to the point where the more I read about the differences between abstract classes and interfaces the more confused I become. So far, neither can be instantiated. Interfaces are more or less structural blueprints that determine the skeleton and abstracts are different by being able to partially implement code.

What are abstract classes and abstract methods?

I got several explanations but so far I’m not able to understand that what are the abstract classes and methods in Java.
Some said it has to do something with the security of the program, other said it isn’t anything like that.
Even from the Dietel & Dietel’s book I don’t get it’s purpose.
When, where and why do we use it?

Questions about Polymorphism

So I understand the importance of Polymorphism, including how vital it is. But something I don’t quite understand is what about the Constructor and any inherited Class the initial Base Class may have.