• 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
Using C++ AutoPtr within an Obj C file.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Using C++ AutoPtr within an Obj C file.


  • Subject: Using C++ AutoPtr within an Obj C file.
  • From: John Draper <email@hidden>
  • Date: Thu, 04 Aug 2005 15:59:01 -0700

Hi,

I'm integrating a C++ library of source files into a Cocoa project file. My "controller"
class will be making C++ calls, mostly allocating pointers. I already read the Apple
document describing the limitations of integrating C++ calls from within an Obj C
file (my controller).


First off, I was told I had to change the .m suffix to .mm suffix if I intend to
call C++ code implemented in .cxx files. Not sure if Apple supports the .cxx
suffix - nor could I find anything that says I shouldn't. Should I leave the files
as .cxx?


For instance,  the statement:

 auto_ptr<ClientAuthManager> clientAuth(new ClientAuthManager);

Creates a pointer to a ClientAuthManager object and places it into 'clientAuth' pointer.
The C++ reference says and I quote: "An auto_ptr is a pointer that owns the object to
which it points. Ownership of this object can be transferred to another auto_ptr, but some
auto_ptr always owns the object". Which I hopefully hope will help me with dealing with
disposal of objects they point to.


I intend to use this C++ construct in my "init" method of my "controller.mm" file. Is this
permitted?


I'll post the error messages I get after I've tried a few more things, but first, I just
want to know if it's possible before I spend a huge amount of time for nothing.


I'm weak in C++, especially since I've been using Obj C more often, and am not familiar
with a lot of the newer C++ constructs and features, since the last time I programmed in
C++ was over 20 yrs ago, and back then, C++ was in it's infancy.


I also intend to use statements like this:

  int level=(int)Log::Debug;

Log::initialize(Log::Cout, (resip::Log::Level)level, appname, logfilename);

Is this also permitted? I read and re-read the apple document, but see nothing that
says I couldn't, but want to ask the list first before I wind up getting swallowed up in
error messages (which are often ambigious), only to find that this is not permitted.


Also, the Mac document says that the use of Virtual objects in C++ is not possible...
I also searched the entire "examples" directory and all it's sub-directories for the
use of "auto_ptr" and found NOTHING uses it... and this is very discouraging to me.


Is there anyone out there who can shed some light on this for me?

Please get back to me.

John

John
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Follow-Ups:
    • Re: Using C++ AutoPtr within an Obj C file.
      • From: Scott Ribe <email@hidden>
  • Prev by Date: Re: Where does NSTableView get a cell's size from, if not from cellSize?
  • Next by Date: Re: Core Data Many2Many Relationships
  • Previous by thread: Re: NSMatrix prototype cell
  • Next by thread: Re: Using C++ AutoPtr within an Obj C file.
  • Index(es):
    • Date
    • Thread