• 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: Question on Objective C++
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Question on Objective C++


  • Subject: Re: Question on Objective C++
  • From: Lance Bland <email@hidden>
  • Date: Wed, 6 Mar 2002 13:36:22 -0500

last time I checked ...

On Wednesday, March 6, 2002, at 12:46 PM, Oscar Morales Vivs wrote:

The docs state that the only C++ object instances that you can put in an Objective-C object are those that don't have virtual functions.

I find that hard to believe. The docs must be wrong. It probably means you can only place pointers and new them on the freestore. You probably can't have value or reference definitions.

It also says that constructors and destructors won't be called when init/dealloc the object.

That's pretty obvious. You have to init and delete them yourself, just like regular freestore.

However: is there some kind of default initialization done on the instance data of an Objective-C object?

It sets the ivar pointer (and everything else) to 0 with a big bzero() call. However, I don't like relying on that and I zero every ivar myself.

The C++ objects I plan to use as instance variables are smart pointers which would be fine if they were initialized to 0 (as I could later change their value in init) but would cause me no end of troubles if garbage were left on them.

There should only be "garbage collection" on non-freestore c++ objects when they exit scope, just as usual.

The docs didn't make it clear on this point.

It is not a standard. You also probably can't pass by reference or define variables by reference or value as ivars.

I didn't write the obj-c++ compiler, so my detail may be "lacking".

-lance


_______________________________________________
Lance Bland
System Administrator at VVI
mailto:email@hidden
http://www.vvi.com
Realtime, bulk and web data reporting and visualization
_______________________________________________
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: Question on Objective C++
      • From: Chris Thomas <email@hidden>
References: 
 >Question on Objective C++ (From: Oscar Morales Vivó <email@hidden>)

  • Prev by Date: Question on Objective C++
  • Next by Date: Re: Document Icons not showing up in Finder?
  • Previous by thread: Question on Objective C++
  • Next by thread: Re: Question on Objective C++
  • Index(es):
    • Date
    • Thread