Is there anything similar to struct inheritance in Objective-C?
For example, C++ allows me to do something like:
struct animal {
int weight;
string name;
}
struct dog : animal {
string breed;
}
struct cat : animal {
bool playsWithLaserPointer;
}
Is there any way to do the same thing in Objective-C without resorting to Objective-C++?
structs in structs work:
struct animal {
int weight;
char *name;
};
struct dog {
struct animal base;
char *breed;
};
struct cat {
struct animal base;
bool playsWithLaserPointer;
};
Apple uses this in CGRect with CGPoint and CGSize
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With