I'm pretty sure you can't do that for two reasons:
- You can't repeat instance variables (
int x, double x).
- It's pretty sketchy to inherit from one class, but then want to change the type of its instance variables.
If you don't want to make separate classes for these use-cases, perhaps an abstract superclass would work. If I more about what you're trying to solve, I'd be able to be a bit more helpful in this area.
What it seems like you really want is parametric polymorphism, which Objective-C does not support. Certain Cocoa classes, like the NSNumber family, use an abstract superclass with many concrete subclasses, presumably with different instance variable layouts (like you describe in your question). Then, logic is divided appropriately between the abstract and the specific. This is Cocoa's Class Cluster design pattern, which is a sort of weakened, ad-hoc answer to the parametric polymorphism of languages like C++ and Haskell.
idis a pointer data type andxandyare primitives.