Re: Bridging C++ to Cocoa?
Re: Bridging C++ to Cocoa?
- Subject: Re: Bridging C++ to Cocoa?
- From: Graham Reitz <email@hidden>
- Date: Sat, 17 Nov 2007 18:51:36 -0600
I looked over some of the ogre examples and it almost looks like you
can use C++ classes right in Object-c++. Is that right?
That is not right. I created a simple Cocoa application with the
Xcode wizard and tried to import a really simple C++ class called
test.hpp and the compiler had no idea what to do.
Let's say I had the existing C++ class (below) and I wanted to use it
in a Carbon application. How would I go about doing that?
Thanks much in advance,
graham
#ifndef _TEST_HPP_
#define _TEST_HPP_
#include <string>
#include <iostream>
class test
{
int m_i;
std::string m_s;
double m_d;
bool m_b;
public:
test()
{
m_i = 1;
m_s = "test";
m_d = 1.1;
m_b = false;
std::cout << "test default constructor called\n";
}
test(int i, std::string &s, double d, bool b) :
m_i(i), m_s(s), m_d(d), m_b(b)
{
std::cout << "test constructor called\n";
}
void get(int &i, std::string &s, double &d, bool &b)
{
i = m_i;
s = m_s;
d = m_d;
b = m_b;
}
~test()
{
std::cout << "test destructor called\n";
}
};
#endif // _TEST_HPP_
Any help would be greatly appreciated.
On Nov 17, 2007, at 5:57 PM, Graham Reitz wrote:
Thanks Filipe,
I looked over some of the ogre examples and it almost looks like you
can use C++ classes right in Object-c++. Is that right?
graham
On Nov 17, 2007, at 11:03 AM, Filipe Varela wrote:
Hi
Have a look at Obj-C++. Basically, c++ instances can exist as
"properties" inside any Obj-C class (compile with Obj-C++) much
like any ansi c type or Obj-C instance.
I use it all the time to build cocoa GUIs to stuff i have in
portable c++.
I also recommend having a look at Ogre Cocoa front ends. While you
may not be interested in Ogre itself (3D), the Cocoa samples are
really simple and should allow you to understand how to mix c++
with Cocoa/Obj-C++
Cheers,
Filipe
On 2007/11/17, at 16:07, Graham Reitz wrote:
Hello,
Could someone point me to a simple example of bridging straight C+
+ classes to an Objective-C/Cocoa gui?
For example, I have several C++ classes that compile on mac,
linux, and windows and would like to feed their output to a
Objective-C/Cocoa based gui. How do I go about that? I just got
started and am on the steep slope of the learning curve.
Thanks much,
graham
I just switch to mac this year, yea! Loving it.
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden