the linking error is because you need to make your body iterator a "static" function. in your header file, change the definition from:
- Code: Select all
void myIterator(OgreNewt::Body* body );
to:
- Code: Select all
static void myIterator(OgreNewt::Body* body );
this means that no matter how many copies of the class you make, only 1 copy of this function will ever exist. this is a requirement for the function pointers that are used.
also I'm not sure I understand your question here:
Also something that seems abnormously wierd for me is that you declare the OgreNewtonApplication with a 'not' ? Is it a not-class ?
from the code you posted I think you mean the "constructor" and "destructor". these are 2 special functions that will be called when an object of that class is created. for example, say you had a class like this:
- Code: Select all
Class MyClass
{
public:
void doSomething();
private:
int myVariable;
};
and you want to initialize the "myVariable" to "3" anytime you use a "MyClass". you would add a "constructor" like this:
header file- Code: Select all
class MyClass
{
public:
MyClass();
void doSomething();
private:
int myVariable;
};
source file- Code: Select all
#include "MyClass.h"
MyClass::MyClass()
{
myVariable = 3;
}
then, in your game or whatever, if you do this:
- Code: Select all
MyClass test;
test.doSomething();
on that first line, the object of type "MyClass" is created, and the "constructor" is called, where the internal variables are setup, or anything else you want to do.
similar to the "constructor" is the "Destructor", which is called when the object is destroyed, and is defined with a "~", like in the code above.
if you want to learn more C++, I HIGHLY recommend the book below, it's entirely free over the internet, and is really well written.
Thinking in C++ (volume 1 and 2)
http://www.mindview.net/Books/TICPP/ThinkingInCPP2e.html
or in PDF format here:
http://www.planetpdf.com/developer/article.asp?ContentID=6634
Independent game developer of (mostly) physics-based games. Creator of "JellyCar" and lead designer of "Where's My Water?"