Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: sharing c++ class



It's possible. As long as you know about all the problems with changing a C++ class after other people start using it. Reordering / changing method signatures is a no-no. Changing the size of member functions: also bad.

A good way to do it is to ship a library that exports one C symbol that returns a pointer to an instance of a class, but declare that class as a pure virtual class. This allows you more freedom in the implementation of the class itself. Adding functions is still a pain, but you can always add new "interfaces" (like creating MyInterface2 to handle new methods) if you need to. This might smell like COM to you, and yeah, it's part of it.

Not to get up on a soapbox, and not trying to pick a fight with anybody, but this is one of the reasons the Cocoa types love Objective-C ... linking is much, much easier (at the cost of some overhead for calling methods).

Alexander Cohen wrote:

So that would be the only way. Its not possible to have a library that exports a C++ class?
_______________________________________________
carbon-development mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/carbon-development
Do not post admin requests to the list. They will be ignored.

References: 
 >Re: sharing c++ class (From: Tom Becker <email@hidden>)
 >Re: sharing c++ class (From: Alexander Cohen <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.