http://GameProgrammer.Com

Programming

GP Mailing List
     Thread Index
     Date Index

ATXGPSIG List
     Thread Index
     Date Index

Google
>

Home

Wise2Food



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Vectors in C++



Greetigns all,

I am teaching myself vectors adn have a pretty good grasp of them but I am
having trouble when attempting to create a multidimensional vector of
classes. I am trying to have an array that will hold an 'X' and 'Y'
cood and when accessed return the information in the class at that
location. 

i.e.
class cSquare{
//some stuff, mutators, inspectors,private data members,etc.
  cSquare();
  void SetFlag(bool);
  bool GetFlag();
};

vector< vector<cSquare> > vBoxes;

What I want to know is how do I access or set a member.  Currently I am
doing something like this:

vBoxes[x][y].SetFlag(true);
if(!vBoxes[x][y].GetFlag())
{
  //do stuff...
}

My code compiles ok but it doesn't seem to be setting my flags right.
Does anyone know of a tutorial anywhere on vectors?  Or am I missing
something?  My book has maybe 3 pages on multidimensional vectors and they
are all for char type only.  Another question I have is, when I declare my
vector, is it automatically initialized using the default constructor of
cSquare?

Thanks for all the help in advance!

Rob <===Wannabe old fart game programmer

=================================================================
The GameProgrammer.Com mailing list is for the open discussion
of any topic related to the art, science, and business of
programming games. This list is especially tolerant of beginners.
We were all beginners once

To SUBSCRIBE or UNSUBSCRIBE please visit:
http://gameprogrammer.com/mailinglist.html