• 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: "Timothy J. Wood" <email@hidden>
  • Date: Wed, 6 Mar 2002 10:35:51 -0800

The +alloc/+allocWithZone: methods (and thus pretty much all ObjC object creation unless you do something extremely strange) will zero fill ObjC objects when they are created.

Note that just because ObjC won't call you constructors doesn't mean that you can't call some initialization code (i.e., you don't have to live with all zeros if it isn't convenient). In your ObjC initialization method you can call a method on your C++ object that does initialization -- it just won't be the constructor (this may require you to factor the guts of your constructor into a 'init' method).

-tim


On Wednesday, March 6, 2002, at 09:46 AM, Oscar Morales Vivs wrote:

Hi there. I'm trying to build a Cocoa front-end to a bunch of C++ code I have. I've read the Objective-C++ documentation and it seems it will work fine for me. There's a couple of doubts I have, however.

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. It also says that constructors and destructors won't be called when init/dealloc the object. However: is there some kind of default initialization done on the instance data of an Objective-C object? 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. The docs didn't make it clear on this point.

Thanks in advance for your help.

Oscar Morales.
_______________________________________________
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.

References: 
 >Question on Objective C++ (From: Oscar Morales Vivó <email@hidden>)

  • Prev by Date: Re: Localizing about files
  • Next by Date: Re: Question on Objective C++
  • Previous by thread: Re: Question on Objective C++
  • Next by thread: Re: Question on Objective C++
  • Index(es):
    • Date
    • Thread