vector problem

This is a discussion on vector problem within the Game Programming forums, part of the General Programming Boards category; Ok so i have a particle class and particle generator class and in the generator class i have a vector ...

Hard to tell without seeing more of the code but are you sure you've added 'using namespace std' or equivalent in that file? Also are you sure you that you don't have a circular include problem? You could try storing the pointer to the object (which incidently, is the preferred way).

"...the results are undefined, and we all know what "undefined" means: it means it works during development, it works during testing, and it blows up in your most important customers' faces." --Scott Meyers

Do this for all your includes and this should fix the include problem. And you still must include <vector> in your code because even though the IDE understands what <vector> is, the compiler/linker will still fail to recognize it. The IDE is deceiving you into thinking since it knows the prototype for vector that you don't have to include it. Wrong. The IDE feature is just something nifty that MS included to aid you in programming so that you don't have to flip back and forth between the help file and/or include file and your source code file.

To test this theory use the Win32 TransparentBlt() function and attempt to link. The compiler will show you the prototype and everything, but it will fail to compile due to an unresolved external reference. Then link your code with msimg32.lib and it will work.

Alright bubba i will have to try that and see what i get, by the way guys sorry for late responses to your responses, i am in college and there is a lot of stuff i have to do befor i can even think about game programming every day so sorry , and thanks for all the help guys.

You really only need to do that for definition (header) files. Reason being, if you include the file more than once (like, if you include that file indirectly) the compiler will think you are also defining the data types more than once.

That is how I always begin writing a class definition in a header file:

#ifndef CLASSNAME_H
#define CLASSNAME_H

#endif

The CLASSNAME_H is just some macro name you choose...the compiler will associate that name with the contents of the header file. If you include the header file more than once, the compiler will only compile the first time it sees it, then it will just skip it because it's already been compiled.