Both bounding box and cube take a few arguments in their constructor
Header:
#ifndef WALL_H
#define WALL_H
#include "cube.h"
#include "BoundingBox.h"
class Wall
{
private:
Cube* cube;
BoundingBox* boundingBox;
public:
Wall(D3DXVECTOR3 min, D3DXVECTOR3 max);
~Wall();
void Draw(D3DXMATRIX matView, D3DXMATRIX matProjection);
};
#endif
Source:
#include "Wall.h"
Wall::Wall(D3DXVECTOR3 min, D3DXVECTOR3 max)
{
cube = new Cube(D3DXCOLOR(255, 20, 20, 255), min, max);
boundingBox = new BoundingBox(min, max);
}
void Wall::Draw(D3DXMATRIX matView, D3DXMATRIX matProjection)
{
cube->Draw(matView, matProjection);
}
Wall::~Wall()
{
delete cube;
delete boundingBox;
}
My question is, how would I modify these classes so that cube and boundingBox are not pointers but simply instances? thanks in advance.
Quite simple. Just like this:
source: