Answer the question
In order to leave comments, you need to log in
How to implement COP in C++?
I was reading articles on Habré, and then I came across an article about COP. I was like: WHAT? update something in the function, you need to make 100500 changes, and in the COP just fix the component. Also, in the COP you don’t need to make a complex class hierarchy like in OOP "
I thought maybe advertising too? I look like Habr, there seems to be no nonsense about dropping fat, drinking a glass at night.
So my pointless epilogue is over, and here are the questions?
1. Is COP as good as it is praised?
2.How can I implement this in C++ or will I have to settle for OOP?
PS
K component
O objective
P approach
Answer the question
In order to leave comments, you need to log in
What you call "COP" has long been used in OOP and is called Composition over inheritance. This is when composition is used instead of inheritance.
For example, inheritance would be like this:
class Person {
String name;
}
class Employer : Person {
BigDecimal salary;
}
class Person {
String name;
}
class Employer {
Person person;
BigDecimal salary;
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question