C++ class

BlitzMax Forums/BlitzMax Programming/C++ class

The Forum Archive is locked. These are the original blitzbasic.com forums, kept so their posts can still be read and searched. No new topics, replies or edits can be made here. To join the conversation, head over to the Blitz3D+ forums.

Perhaps something along the lines of this completely untested code :

test.cpp
class MyClass
{
public:
   MyClass();
   void DoSomething();
}

MyClass::MyClass()
{}

void MyClass::DoSomething()
{
}

extern "C" {

  MyClass * create_new_myclass();
  void myclass_dosomething(MyClass * myclass);

}

MyClass * create_new_myclass() {
    return new MyClass();
}

void myclass_dosomething(MyClass * myclass) {
    myclass->DoSomething();
}


testwrap.bmx
Superstrict

Import "test.cpp"

Extern
  Function create_new_myclass:Byte Ptr()
  Function myclass_dosomething(myclass:Byte Ptr)
End Extern

Local b:Byte Ptr = create_new_myclass()

myclass_dosomething(b)