Sign in to follow this  
NavalFC

Direct X visual studio issue

Recommended Posts

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.

Share this post


Link to post
Share on other sites
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:
[code]
// 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
}
[/code]

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this