Note that there are some explanatory texts on larger screens.

plurals
  1. USslaw
    primarykey
    data
    text
    plurals
    1. This table or related slice is empty.
    1. CO@drescherjm: Thanks, you were right. The Person struct should have been protected. I've corrected it now. However, can you suggest how I can add a member to the Person struct for the derived class? Or, should I leave the Person struct as private in the base class (so that the Person struct cannot be accessed but the methods are inherited) and then define a new, derived struct (as suggested below) to be used in the derived class?
      singulars
    2. CO@drescherjm: In reality, there are many functions that I would like to inherit from the base class. For simplicity, only one function is shown. But the real question is whether it is possible to add a member to the struct in the derived class. And, if not, how can I work around this since I would like to extend the base class.
      singulars
    3. CO@KarolyHorvath: Can you explain why this question is "off-topic"? There is a library that I am using and I would like to extend the class through inheritance. However, the base class contains a struct that I would like to add a member to but don't understand how to. When I say "fictitious example", I am referring to the example given but my actual code encompasses the same problem and follows the "question checklist" of a "as a short but complete program" to get the point through. Please enlighten me. If I can modify my question then I would be happy to.
      singulars
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload