Hi all
I am porting most of my C++ code into Objective C and at the moment I
have this problem:
In C++ to force a constructor to call a overriding method of a
subclass I used pure virtual functions defined in an abstract (super)
class.
An example:
class Foo
{
Foo();
virtual read( x, y ) = 0; // pure virtual
};
class Bar : public Foo
{
Bar();
virtual Read( x, y ); // implemented in the subclass
};
// Foo constructor
Foo::Foo()
{
Read( x, y ); // <-- this calls Bar::Read and not Foo::Read
// because the latter is pure virtual
}
I know that the closest thing to a pure virtual function in Objective
C is a formal protocol. My question is: can you implement such a
behavior in objective C with a formal protocol?
Related to this, what method gets called inside the init method of the
superclass: a) the superclass method? or b) the overriding method if
there is one?
Although this is not strict Cocoa code, I think this is the best place
to ask this kind of question. Sorry for the mild "OT-ness" of my
question.
TIA
JV
_______________________________________________
Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com
This email sent to arch...@mail-archive.com