Direct X visual studio issue

Started by
0 comments, last by Buckeye 13 years, 2 months ago
Im trying to write a class for each type of sprite (Bullets, enemy sprites etc) and one member of them all I want to be is their current position
so I try having the following in each class:
D3DXVECTOR3 pos(0,0,0)

but visual studio underlines all 3 0s in red, saying I need a type specifier, like it thinks Im doing a function declaration or something.
Yes, I have all needed includes.

The main code file has similiar declarations and gives no errors, yet the individual cpp files for the classes give this error. I dont get what the problem is.
Advertisement
If that declaration is in the header for your base class, then you're trying to initialize pos in the class definition (which would require a call to the D3DXVECTOR3 constructor).

Alternatively, in the class constructor add something like:

// definition
class MyClass
{
MyClass(void);
D3DXVECTOR3 pos;
//.. other stuff
};
// constructor
MyClass::MyClass(void): pos(D3DXVECTOR3(0,0,0))
{
// ... other initialization
}
//=== OR ===
MyClass::MyClass(void)
{
pos = D3DXVECTOR3(0,0,0);
//... other initilization
}

Please don't PM me with questions. Post them in the forums for everyone's benefit, and I can embarrass myself publicly.

You don't forget how to play when you grow old; you grow old when you forget how to play.

This topic is closed to new replies.

Advertisement