Jump to content
  • Advertisement
Sign in to follow this  
NavalFC

Direct X visual studio issue

This topic is 2737 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

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
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
}

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!