• 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
Embedding C++objects in Objective C++
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Embedding C++objects in Objective C++


  • Subject: Embedding C++objects in Objective C++
  • From: Tommy Nordgren <email@hidden>
  • Date: Thu, 30 Dec 2004 14:00:37 +0100

Are there any way to make xcode generate warnings instead of errors, when compiling Objective C++ classes that embed C++ classes with virtual methods. What i want to do is code according to the following pattern (it works if the C++ class has userdefined constructors, but no virtual methods:

class MyCPPClass {
	int nn;
public:
	MyCPPClass():nn(n) {};

	~myCPPClass() {};

	void print() const;

protected:
	virtual void printSelf() const;
};

@interface MyClass : NSObject
{
	MyCPPClass member;
}

- (void) print;
@end

@implementation MyClass

- (id) init
{
[super init];
new ((void *) &member) MyCPPClass(789); //Call constructor myself via placement new
return self;
}


- (void) dealloc
{
	member.~MyCPPClass(); //Explicit destructor call
	[super dealloc];
}

- (void) print
{
	member.print();
}
@end

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


  • Follow-Ups:
    • Re: Embedding C++objects in Objective C++
      • From: Clark Cox <email@hidden>
  • Prev by Date: Re: Prebinding strategies
  • Next by Date: Using custom build rules
  • Previous by thread: file name conflict
  • Next by thread: Re: Embedding C++objects in Objective C++
  • Index(es):
    • Date
    • Thread