Skip to main content
GameDev.net gamedev.net
🔒 Locked

Declaration of a vector? (canceled)

Started by MarauderX Aug 1, 2006 at 2:13 PM 5 replies 700+ views
Original Post
MarauderX
MarauderX
Can someone please tell me how to create a private vector for my cameras? I looked at different tutorials, but every time I get the error: "missing ; before [whatever comes after vector]".


#include <vector>
#include <d3dx9.h>

struct STRUCT_CAMERA
{
    D3DXVECTOR3				vEye;
    D3DXVECTOR3				vLookat;
    D3DXVECTOR3				vUp;
    D3DXMATRIXA16			matView;
};

class CCameras
{
private:
	// ToDo: declare a vector to put cameras in

public:
	void Add(D3DXVECTOR3 vLocation, D3DXVECTOR3 vOrientation);
    CCameras();
    ~CCameras();
};




[Edited by - MarauderX on August 1, 2006 3:51:00 PM]
CTar
CTar
class CCameras{private:	std::vector<CCameras> private_vector;public:	void Add(D3DXVECTOR3 vLocation, D3DXVECTOR3 vOrientation);    CCameras();    ~CCameras();};
MarauderX
MarauderX
I need the structure to be in the vector. But I get errors in the vector header.
Is this right? I changed the structure:

#include <vector>#include <d3dx9.h>typedef struct{    D3DXVECTOR3				vEye;} STRUCT_CAMERA;class CCameras{private:	std::vector<STRUCT_CAMERA> cams;	};

MarauderX
MarauderX
My real question is now:

Why can I put a class in a vector:
vector cams;

but not a typedef struct?
vector cams;

Driv3MeFar
Driv3MeFar
Why even bother with the typedef? Its not needed in C++.
jpetrie
jpetrie
The typedef struct business is an ugly C-ism you should avoid in C++.
It should, however, work. What is the actual code you tried, and the actual error it generated?
MarauderX
MarauderX
Please see my next topic I posted. Sorry for the inconvenience

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.