A
ADT_CLONE
I am having trouble with headers at the moment. Here is the code for a
start:
body.h:
#pragma once
#ifndef BODY_H
#define BODY_H
class body
{
private:
joint* jointList;
};
#endif
joint.h:
#pragma once
#ifndef JOINT_H
#define JOINT_H
class joint
{
public:
int getRelativeX(){return r_X;}
int getRelativeY(){return r_Y;}
private:
//The x variable is actually relative to the master body
int r_X;//Relative X
int r_Y;//Relative Y
body* r_Body;//Relative Body
};
#endif
main.cpp:
/*--------Declarations--------*/
#include <iostream>
#include "joint.h"
#include "body.h"
using namespace std;
int main()
{
cout<<"Hello World";
cin.get();
return 1;
}
Now the problem I am encountering is that when I compile this it has
errors with the following line:
body* r_Body;//Relative Body
I know this is because somehow the headers haven't linked properly.
The problem is that joint needs body and body needs joint. So how
would I do this, because I'm stumpted. Thanks for your help in advance.
start:
body.h:
#pragma once
#ifndef BODY_H
#define BODY_H
class body
{
private:
joint* jointList;
};
#endif
joint.h:
#pragma once
#ifndef JOINT_H
#define JOINT_H
class joint
{
public:
int getRelativeX(){return r_X;}
int getRelativeY(){return r_Y;}
private:
//The x variable is actually relative to the master body
int r_X;//Relative X
int r_Y;//Relative Y
body* r_Body;//Relative Body
};
#endif
main.cpp:
/*--------Declarations--------*/
#include <iostream>
#include "joint.h"
#include "body.h"
using namespace std;
int main()
{
cout<<"Hello World";
cin.get();
return 1;
}
Now the problem I am encountering is that when I compile this it has
errors with the following line:
body* r_Body;//Relative Body
I know this is because somehow the headers haven't linked properly.
The problem is that joint needs body and body needs joint. So how
would I do this, because I'm stumpted. Thanks for your help in advance.