Objective-C method overriding/overloading confusion -


there seems debate/disagreement on whether possible 'overload' methods in objective-c. putting aside impossible define method overloading in objective-c terms equal of c++ (because of method signature syntax differences), ask in particular: of following allowed , not?

1) class declaring/implementing both these methods:

- (void) dosomethingwithobject:(classa*) object; - (void) dosomethingwithobject:(classb*) object; 

2) class declaring/implementing both these methods:

- (void) dosomethingwithobject:(classa*) object; - (bool) dosomethingwithobject:(classa*) object; 

3) class declaring/implementing method:

- (void) dosomethingwithobject:(classb*) object; 

...when superclass declares/implements method:

- (void) dosomethingwithobject:(classa*) object; 

(and analogue conflicting return value), both when a) classb descends classa, , b) not.

question 1: no can do: objective-c doesn't include types in method names; there no mangling. might work objective-c++ -- never used much.

question 2: same. won't work.

question 3: work.

edit: in general, method names not include types, if strip types , same considered same, , therefore won't allowed in same class. along same lines, work if it's in different classes, although might confusion if types used in call , types used in gets called don't quite agree.


Comments

Popular posts from this blog

javascript - backbone.js Collection.add() doesn't `construct` (`initialize`) an object -

php - Get uncommon values from two or more arrays -

Adding duplicate array rows in Php -