Re: vtables in objc++
Re: vtables in objc++
- Subject: Re: vtables in objc++
- From: Oscar Morales Vivó <email@hidden>
- Date: Mon, 24 Feb 2003 09:30:55 +0100
I can't comment on your error (are you sure using the .mm suffix and
all?) I do have some advice, having done some Objective-C coding.
Remember that Objective-C (and by extension Objective-C++) zeroes all
instance variables when creating an object. That's why you can't use
C++ objects with virtual functions, as the vtable pointer won't get
initialized.
HOWEVER, neither can you use any other object which doesn't have a
valid value if it's all zeros. For example, a std::list won't work in
my experience (needs to have some pointers at non-zero value), and my
guess is that a std::deque also won't (not sure about std::vector, but
as it's probably implementation-dependent I wouldn't try it).
So your best bet is to keep all non trivial objects referenced through
pointers. Create them using new in the init method, and destroy them
using delete in the dealloc method. Of course more complex ways of
doing it are possible (if someone wants an already tested in
Objective-C++ smart pointer implementation just ask me).
Hope that helps.
On Sunday, Feb 23, 2003, at 13:38 Europe/Madrid, daniel oberhoff wrote:
i just encountered this:
ld: Undefined symbols:
vtable for CustomControlElement
i am NOT using instance variables with virtual functions but rather a
deque which holds thos :).
does this mean now i cannot use anything to do with virtual functions
(and thus method overwriting) in objc++?
daniel
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.