objective c - Multiple instance variable types for class? -


is possible handle class different instance variable types? let's have class has 2 int instance variables, let's call them:

@interface classa: nsobject {   int x;   int y; } @end 

at same time want extend giving possibility handle different type on such instance variables so:

@interface classb: classa {   double x;   double y; } 

is possible?

i'm pretty sure can't 2 reasons:

  1. you can't repeat instance variables (int x, double x).
  2. it's pretty sketchy inherit 1 class, want change type of instance variables.

if don't want make separate classes these use-cases, perhaps abstract superclass work. if more you're trying solve, i'd able bit more helpful in area.

what seems want parametric polymorphism, objective-c not support. cocoa classes, nsnumber family, use abstract superclass many concrete subclasses, presumably different instance variable layouts (like describe in question). then, logic divided appropriately between abstract , specific. cocoa's class cluster design pattern, sort of weakened, ad-hoc answer parametric polymorphism of languages c++ , haskell.


Comments

Popular posts from this blog

Add email recipient to all new Trac tickets -

400 Bad Request on Apache/PHP AddHandler wrapper -

php - Change action and image src url's with jQuery -