Jump to content
  • Advertisement
Sign in to follow this  
daniel_i_l

C++ ctor

This topic is 4366 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi, i have the following structure:
struct Matrix3D
{
	//3 coloum vectors
	Vector3D C[3];

	//ctor - identity matrix
	Matrix3D():C[0].x(1), C[1].y(1), C[2].z(1){}
	//ctor - user defined
	Matrix3D(const Vector3D &c0, const Vector3D &c1, const Vector3D &c2)
		:C[0](c0),
		 C[1](c1),
		 C[2](c2)
	{}
...
...
};

but in both of the ctors i get the error: c:\documents and settings\daniel lowengrub\my documents\visual studio 2005\projects\physic\physic\physic\Matrix3D.h(16) : error C2059: syntax error : '[' What's the problem? Thanks.

Share this post


Link to post
Share on other sites
Advertisement
You can't construct the elements of an array in an initializer list like that. Just do it in the body of the constructor.

struct Matrix3D
{
//3 coloum vectors
Vector3D C[3];

//ctor - identity matrix
Matrix3D()
{
C[0].x = 1;
C[1].y = 1;
C[2].z = 1;
}
//ctor - user defined
Matrix3D(const Vector3D &c0, const Vector3D &c1, const Vector3D &c2)
{
C[0] = Vector3D(c0);
C[1] = Vector3D(c1);
C[2] = Vector3D(c2);
}
...
...
};

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!