Re: using a virtual C++ function
Re: using a virtual C++ function
- Subject: Re: using a virtual C++ function
- From: Oscar Morales Vivó <email@hidden>
- Date: Tue, 10 Jun 2003 14:01:07 +0200
You should use Objective-C++. Append '.mm' to your code files (instead
of '.cpp' or '.m' to have both languages on. Class hierarchies can't
mix, but it works well enough).
And then create a bridge class that handles the C++ object and just
calls the C++ functions on its Obj-C methods.
I do it all the time without a lot of trouble. If you really need more
detail just ask me.
On Monday, Jun 9, 2003, at 22:48 Europe/Madrid, Robert Palmer Jr wrote:
I'm trying to learn Cocoa and Objective C (for about the 3rd or 4th
time). I've looked through the archives for an answer, but haven't
found one.
I have a C++ class with a virtual function that is expected to be
overridden.
class SensorFinder
{
public:
SensorFinder();
virtual ~SensorFinder();
void search();
virtual void sensorFound(char hwAddr[6]){};
}
When search() is called, it queries the network for sensors. For each
sensor found, search calls the sensorFound() function. This is an
interface to the searching core. To use this, your "real" app would
derive from SensorFinder and implement sensorFound() and do something
(build a table/NSMutableArray) with each sensor found.
Now, I want to USE this in a cocoa application. Unfortunately, I
can't derive an objective-C class from a C++ class. I want to create
an NSTableView dataSource object and use this SensorFinder class to
populate it. What is the best way to go about this???
Thanks,
-----------------------------
Robert G. Palmer, Jr.
email@hidden
_______________________________________________
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.
/*
Oscar Morales Vivs
Eternal Computer Science Student. Master of C++ Templates. Cocoa Nut.
Computer Graphics Illuminati. UI Guru in Training. Dabbler in all
things CS and most which are not.
Web stuff:
http://homepage.mac.com/oscarmv/index.html
*/
_______________________________________________
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.