Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

linus78

STL vector

This topic is 6244 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, Im trying to get a piece of code to work, but I cant =). I want to make a STL vector of all my objects that I have in a GLscene. I have a class called OBJECT which contains the object to be drawn. Anyway here is the code:
    
//--------------------------------------------------------------

#include <windows.h>

#include <gl\gl.h>

#include <gl\glu.h>

#include <gl\glaux.h>

#include <vcl.h>

#include <math.h>

#include <vector>

#include "object.h" <- contains the class OBJECT

vector  <OBJECT> objectlist; <- Gives me a compile error, says declaration syntax error

int main()....
//--------------------------------------------------------------

    
Ive been trying to get it to work but I cant. I can code a simple list instead but I want to use STL vector, mostly to learn it. So if anyone knows whats wrong please help me. btw Im using Borland C++ builder 5.02. Thanks /Linus Edited by - linus78 on September 8, 2001 9:36:12 PM Edited by - linus78 on September 8, 2001 9:36:48 PM

Share this post


Link to post
Share on other sites
Advertisement
Guest Anonymous Poster
you might want to try putting "using namespace std" before you declare your vector.

Share this post


Link to post
Share on other sites
or you can try to access the namespace directly.
I had a conflict once that couldnt be solved with using namespace
so i access directly

  
#include <vector>

std::vector<OBJECT> vObjects;





{ Stating the obvious never helped any situation !! }

Share this post


Link to post
Share on other sites
You could also say something like this:

#include...
// include all of your stuff here

using namespace std;

void main()
{
// your program here
}

Just add that using namespace std; line and you won''t have to type std::vector every time. It just saves you some typing and makes it look a little cleaner.

Share this post


Link to post
Share on other sites

  • 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!