Force a class to have an attribute

Asked

Viewed 37 times

0

I am doing a project and I need a parent class (heritage) to force its daughter classes to have a certain attribute. It is possible to do this?

  • 2

    If the mother class has an attribute, all daughters will have it. It is not clear.

  • Pq there is a method that all daughter classes have to perform at the time of their creation, and this function needs an attribute that it must clone from a prototype. I wanted to make sure he forces his daughters to seek that attribute.

  • No constructor? Simply call the parent class when creating the constructor (public SubClass(int param) : SuperClass(int param) { ... })

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.