Problem with bool vectors

EDIT: The code works when i have only 2 vectors, but once i get 3 i get this error.

I'm making my first tile based game and i want to use a bool vector to store whether or not a tile is passable, i have tried this:

1
2
3

std::vector< std::vector<bool> > bCanWalkThrough(100, std::vector<bool>(100));


it compiles fine, however i get an error:

Run-Time Check Failure #3 - The variable 'iPlayerLocationsY' is being used without being initialized.

This error is wrong though, as it works fine before i use a bool vector, so what's really the problem?
Last edited on
i cant understand what is your problem !!

vector<vector<bool> > v(100, vector<bool>(100)); compile without error .

but you must know one thing :
vector<bool> is user-define of template<Type> vector !!!
and differ with vector
Last edited on
Run-Time Check Failure #3 - The variable 'iPlayerLocationsY' is being used without being initialized.
Is that your problem? The lin ypu posted shouldn't have any problems.

That an error like this occurs doesn't mean that the last thing you added is the reason why. It was always there but now (thru an innocent change) it's getting obvious
Everything worked fine before i decided to use a vector instead of an array, i tested the game and everything worked fine.

Is there some problem that could occur when transfering from using a bool array to a vector? Since the int vector worked with my old int array code, i haven't changed anything with the old bool array code as i suspected it would work ok.
Ok...I just tested something and now i am completely puzzled. I changed one of my int vectors to a int array and now it works, with the bool vector there. So it seems to cause this problems when i have 3 vectors...
i told you vector<bool> is user-define of vector and differ with vector ! i dont see your code and i cant have any idea . but in c++ have another class for boolean type : bitset
check it
As long as you stay within the limits of the vector (it doesn't increase automatically!) everthing should be ok. The problem is certainly not the vector. Uninitialized variables are more a problem...

@ ahura24
He created a 2d vector. You can't do that with bitset
Umm, not sure how to do that, here are my defines:

1
2
3
4
#include <SFML/System.hpp>
#include <SFML/Graphics.hpp>
#include <iostream>
#include <vector> 


I could post all my code, but it's a lot.
yes i know @coder 777 but he can use
vector<bistset<100> > v( 100 );
:)) hey man why you use SFML :)) almost everyone i know problem with this game engine .
why you dont exam ClanLib . i work with SFML and ClanLib , my idea ClanLib is too better
@coder

Dude it can't be the variable, it's declared in my main loop and worked no problem. The error says it hasn't been declared in the third if statement i use it, the error is bogus. You say i should stay within the limits of vector, well when i use 2 vectors it works, at 3 it doesn't, so do i have to increase this somehow or?

@ahura

SFML was recomended to me by loads of people for 2d game programming, i haven't had any problems with it and it's been great.
Last edited on
Lol i deleted the code the error was complaining about and i get the exact same error that points at code that doesn't exist. And the code isn't needed to run the game properly i just put it there for convenience.
Last edited on
Topic archived. No new replies allowed.