• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: using a virtual C++ function
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: using a virtual C++ function


  • Subject: Re: using a virtual C++ function
  • From: "Florian G\. Pflug" <email@hidden>
  • Date: Tue, 10 Jun 2003 10:13:17 +0200

On Mon, Jun 09, 2003 at 04:48:35PM -0400, Robert Palmer Jr wrote:
> 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]){};
> }
>

class ObjCSensorFinder
{
public:
SensorFinder(id _delegate);
:SensorFinder::SensorFinder()
:delegate(_delegate)
{
[delegate retain] ;
}

virtual ~SensorFinder()
{
[delegate release] ;
}

virtual void sensorFound(char hwAddr[6])
{
[delegate foundSensor: hwAddr] ;
}

protected:
id delegate ;
}

Then write a ObjC Class for storing lists of sensors, and manipulating them
(conceptually, this class would be part of the controller of your app).
The controller should have an instance of ObjcSensorFinder as a instance
variable, (of course initializing ObjcSensorFinder with self as delegate),
and call myfinder.search() when it needs to update the list of sensors.

If course ObjcSensorFinder could add entries to an NSMutableArray or
NSDictionary directly, but I believe using an informal interface here
decouples those two parts far better.

greetings, Florian Pflug
_______________________________________________
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.

  • Follow-Ups:
    • Re: using a virtual C++ function
      • From: Robert Palmer Jr <email@hidden>
References: 
 >using a virtual C++ function (From: Robert Palmer Jr <email@hidden>)

  • Prev by Date: Rép : PPP Control
  • Next by Date: Re: PPP Control
  • Previous by thread: using a virtual C++ function
  • Next by thread: Re: using a virtual C++ function
  • Index(es):
    • Date
    • Thread