C++ prob :/
I''ve been rewriting my engine, and its all going pretty damn well, up till about 20 minutes ago.
I added a new movement to my camera class, in-which the first two lines of code were this.
CVector3 vCross = {0};
CVector3 vViewVector = {m_vView.x - m_vPosition.x, m_vView.y - m_vPosition.y, m_vView.z - m_vPosition.z};
but for some reason (im betting a C++ problem), I get these errors.
error C2552: ''vCross'' : non-aggregates cannot be initialized with initializer list
error C2552: ''vViewVector'' : non-aggregates cannot be initialized with initializer list
This is the first time I''ve come across this error and I''m not 100% sure what I''ve done wrong...
Any help appreciated.
"Build a man a fire, and he will be warm for a day. Set a man on fire, and he will have warmth for the rest of his life"
You should take a look at your CVector3 class definition... You can't initialize such class by a list {...} ! Or it should be an array !!
typedef float CVector3[3]; // for example
CVector3 vCross = {0,0,0}; // should be okay
but with
class CVector3
{
...
};
You must have some constructors like these :
class CVector3
{
...
public:
CVector3(float x=0, float y=0, float z=0);
...
};
With an instance of this class :
CVector3 vCross; // default constructor gives a null vector
CVector3 vViewVector(m_view.x -... , ..., ...);
Edited by - brunow on February 10, 2002 7:49:34 PM
typedef float CVector3[3]; // for example
CVector3 vCross = {0,0,0}; // should be okay
but with
class CVector3
{
...
};
You must have some constructors like these :
class CVector3
{
...
public:
CVector3(float x=0, float y=0, float z=0);
...
};
With an instance of this class :
CVector3 vCross; // default constructor gives a null vector
CVector3 vViewVector(m_view.x -... , ..., ...);
Edited by - brunow on February 10, 2002 7:49:34 PM
See... thats the prob, I know the code works. (this particular extract is from http://www.gametutorials.com/ ... and their code compiles with it.
But when I apply it to my own camera class, it doesnt work.. just that part, in the compile process... its odd and I cant wrap my brain around it.
But when I apply it to my own camera class, it doesnt work.. just that part, in the compile process... its odd and I cant wrap my brain around it.
"Build a man a fire, and he will be warm for a day. Set a man on fire, and he will have warmth for the rest of his life"
I retire what I said before !!
you must have the word "public" in the class before (without it you will have the same error msg) :
class CVector3
{
public:
float x,y,z;
};
then you can use :
CVector3 vCross = {0} ...

Edited by - brunow on February 10, 2002 8:02:59 PM
you must have the word "public" in the class before (without it you will have the same error msg) :
class CVector3
{
public:
float x,y,z;
};
then you can use :
CVector3 vCross = {0} ...

Edited by - brunow on February 10, 2002 8:02:59 PM
That''s already there... same error occurs. =(
"Build a man a fire, and he will be warm for a day. Set a man on fire, and he will have warmth for the rest of his life"
Well...... I went, slept, came back and fixed it by changing the lines to this.
CVector3 vCross = CVector3(0,0,0);
CVector3 vViewVector = CVector3(m_vView.x - m_vPosition.x, m_vView.y - m_vPosition.y, m_vView.z - m_vPosition.z);
So that now works perfectly.
But it''s still bugging me how they could use initialiser lists and I couldnt. :/
It''s odd....... very odd..... oh well, w00t anyway, working great now.
Thx for all your help.
CVector3 vCross = CVector3(0,0,0);
CVector3 vViewVector = CVector3(m_vView.x - m_vPosition.x, m_vView.y - m_vPosition.y, m_vView.z - m_vPosition.z);
So that now works perfectly.
But it''s still bugging me how they could use initialiser lists and I couldnt. :/
It''s odd....... very odd..... oh well, w00t anyway, working great now.
Thx for all your help.
"Build a man a fire, and he will be warm for a day. Set a man on fire, and he will have warmth for the rest of his life"
quote:
Original post by Cobra
CVector3 vCross = CVector3(0,0,0);
CVector3 vViewVector = CVector3(m_vView.x - m_vPosition.x, m_vView.y - m_vPosition.y, m_vView.z - m_vPosition.z);
You can change that to this if you''d like:
|

This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement