total is working properly i've narrowed it down further i think. I made everything that involves these references public instead of some privates. now it points to an error in the string class and opens the string class file . heres the entire ImageManager .cpp file. the errors still occur even when calling the function getImage directly from its variable (not a reference)
#include "StdAfx.h"
#include <iostream>
#include "ImageManager.h"
#include <fstream>
ImageManager::ImageManager(void):
total(0),
names(0),
images(0)
{
std::string temp;
std::ifstream file("data/imagelist.txt", std::ios::in);
if ( file.is_open() )
{
while (file.good())
{
file >> temp;
addImage(temp);
}
}
file.close();
}
ImageManager::~ImageManager(void)
{
}
void ImageManager::addImage(std::string name)
{
bool check = false;
std::vector<std::string>::iterator it = names.begin();
while( it != names.end() )
{
if ( (*it)==name )
{
check=true;
}
++it;
}
if (check==false){
total++;
names.push_back(name);
name.insert(0, "graphics/");
name.append(".bmp");
images.push_back(sf::Image());
images.back().LoadFromFile(name.c_str());
images.back().SetSmooth(false);
images.back().CreateMaskFromColor(sf::Color(255,255,255));
}
}
sf::Image& ImageManager::getImage(std::string name) {
int loop = 0;
bool check = false;
for (loop=0;loop<total;loop++){
if (names[loop]==name){ ///// this line pulls an error. and if i try to cout elements of name it also pulls errors.
check=true;
break;
}
}
if (check==true){
std::cout << loop << "LOOP \n";
return images[loop];
} else {
return images[0];
}
return images[0];
}
anytime i try to use the GetImage function it pulls the errors out of the string class file and points to this line in the string file
? 0 : (_Mysizt)_Ostr.width() - _Size;
the program will still execute without debugging and run perfectly fine. just when debugging does it show this. which is an annoyance because i cant debug the rest of my code.
if i run the program without debugging and add a bunch of couts that display what strings names holds it displays the names perfectly.
well i feel like a dumby now. But I still need help. I'm using VSC++ Express 2010. I'm trying to debug my Release build and for some reason my files always fail to open when debugging.. they always open when not debugging. I have the files placed in the same directory paths in the debug and release folders. but is there a special place you have to put them when you Debug a release build?
i just copy pasted the text files into every directory inside the project folder and that has it working now. why doesn't it just fun off the release/debug folders?