• 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
Mixing C++ with Objective C
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Mixing C++ with Objective C


  • Subject: Mixing C++ with Objective C
  • From: John Draper <email@hidden>
  • Date: Tue, 02 Aug 2005 23:21:13 -0700

I tried to post this last week. Got no response from it, nor did I see it appear in
the list. If you hav gotten this before, I apologize... but I urgently need
answers to this question.


This came from: http://developer.apple.com/documentation/Cocoa/Conceptual/ObjectiveC/index.html


Note code below....

#import <Cocoa/Cocoa.h>
struct Class0 { void foo(); };
struct Class1 { virtual void foo(); };
struct Class2 { Class2(int i, int j); };

@interface Foo : NSObject {
Class0 class0; // OK <---- Is this OK because there was no constructor?
Class1 class1; // ERROR!
Class1 *ptr; // OK—call 'ptr = new Class1()' from Foo' init,
// 'delete ptr' from Foo's dealloc
Class2 class2; // WARNING - constructor not called!
...
@end

OK, but I don't see why Class2's constructor is not called. Is that because it
didn't include the arguments... IE:


Class2 class2(i, j); // WOULD this work?

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: Mixing C++ with Objective C
      • From: Justin Kolb <email@hidden>
  • Prev by Date: Re: SVN revision number in CFBundleVersion
  • Next by Date: Question on guidelines of integrating C++ calls inside an Obj C class
  • Previous by thread: Re: NSStatusItem:setImage - Icon not displaying
  • Next by thread: Re: Mixing C++ with Objective C
  • Index(es):
    • Date
    • Thread