Hello, I'm trying to initialize a private variable of my Class passing a const string &aString to it as parameter.
Here's my method:
void Image::initWithTextureFile(const std::string &inTextureName)
{
Texture2D *imTexture = TEXTURE_MANAGER->createTexture(inTextureName);
if(imTexture)
{
texture = imTexture;
scale = 1.0f;
name = inTextureName; //name is a private string variable inside my class
initImplementation();
}else {
printf("Could not load texture when creating Image from file %s\n",inTextureName.c_str());
}
}
My problem is the following, when I call this method I do it like:
myInitializer.initWithTextureFile("myFile.bmp");
When I'm inside the scope of initWithTextureFile
the name
variable takes the value of inTextureName
. For this example if I cout << name << endl;
inside initWithTextureFile
i would get "myFile.bmp"
But when I leave the scope of the function, name
looses it's value, so when i cout << name << endl;
I get nothing printed in the console.
Could anyone point me out to what's going on here?
Name is declared:
private:
std::string name;