Join devRant
Do all the things like
++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
Sign Up
Pipeless API
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
Learn More
So is the difference between inheritance and composition is that of a fridge and iceman?
class Man {
fun greet(){return "hi"}
}
class IceMan extends Man{
override fun greet(){return "hi i am iceman"}
fun getIce(){return "ice"*Random.nextInt()}
}
class Fridge{
private Man manAi;
private String s = "ice";
fun greet(){return manAi.greet()}
fun getIce(){return s*Random.nextInt()}
}
}
=========
Basically , in first case, a class is getting features by inheriting from parent while in another case, a class is getting features by internally having objects of other classes that could provide those features?
question