compiler gives me the error bg was not declared in this scope. what should i do. where i m mistaken.
i googled it. but truely speaking i m lost.
and maybe u might need these
in MCInit #include <SDL/SDL.h> #include "MCLoad.h"
in MCLoad #include <SDL/SDL.h> #include <string>
in MCClean #include <SDL/SDL.h> #include "MC.h"
will u help me pls
is what i did foolish or idiotic or something. i dont know maybe what i did wasnt what i think i did hah. is the problem me asking something so obvious that i m not aware. someone pls tell me something
You haven't shown us enough code to see what's wrong. In particular, you haven't shown us where bg is defined. Hell, you haven't even told us what line causes the compiler error.
Why would you claim to want help, and then withhold the information that would enable us to give you that help?
well i wasnt aware that i m not giving enough info. sorry for that. so that was the thing so obvious that i couldnt see(the part i was foolishly mistaken) :D
algorithm of MC:
MCLoad.h->MCInit.h-->MC.h->MCMain.cpp
MCClean.h-------------| //it goes truogh MC.h
well Load func which is inside MCLoad.cpp takes two variables Name and File and use them to declare an SDL_Surface and creates a surface(see at my first post). this is how bg declared. a function that creates and declares SDL_Surface itself. this is where bg declared. MCLoad::Load(&bg, "gfx\\bg.bmp")
NOTE: MC.h is a header that contains other headers and does nothing it is just a bridge between MCMain.cpp and headers
EDIT: if u want any further info just say it i will anything that is necessery. in my first post i didnt wanted to make u drown with all the project :D
this if((MCLoad::Load(&bg, "gfx\\bg.bmp")) == false){returnfalse;}
1 2 3 4 5 6
int main ( int argc, char** argv )
{
if((MCInit::Init()) == false){return 1;}
return 0;
}
simply telling main calls MCInit::Init func. Init calls Load with using bg and where bg.bmp is. load declares bg at runtime and loads it. then the problem accurs. i cant call bg which is created at runtime it doesnt exist before program run.
NOTE:do u think i m and idiot. if u want i can delete myself from life
Well, it would be trivially easy for you to go and look up what the word "declare" means in the context of C++ programming, if you really felt that you were confused about what it means.
load declares bg at runtime and loads it.
In the definition of Load that you've posted:
1 2 3 4 5 6
bool MCLoad::Load(SDL_Surface* Name, std::string File){
Name = NULL;
Name = SDL_LoadBMP(File.c_str());
if(Name == NULL){returnfalse;}
else{returntrue;}
}
"bg" isn't even mentioned. It's certainly not declared.
EDIT: And it's not declared anywhere else in the code you've posted. You simply suddenly start using the name "bg" without ever declaring it.
the prob here is i thought i would take bg as Name and would declare it like a popcorn. and where i m confused is how it worked when i used it in my main to try and not working in my class. seriously how did i make it worked(i already deleted that file). and now i see the prob thx. what i thought it was some kind of class prob
ty all