SFML community forums
Help => General => Topic started by: infernotnt on August 30, 2016, 02:45:07 pm
-
.........
void foo(RenderWindow window){
window.draw(bar);
}
........
int main(){
RenderWindow window(....);//i have to define it in int main!
foo(window);
return 0;
}
I need the function to work but the problem is that i need to define the window in int main but then i can't use the function, I tried using pointers but I suck with pointers so that was no good, offer a solution please.
-
You can't define or declare a function within another function.
Use a reference instead of trying to pass a copy.
Additionally I advice you to first learn a bit more about C++ itself before jumping into using other libraries.
-
Okay, just tell me how do I do it, I will be very happy, I have a few years of problem solving expirience in c++ so I suck with pointers as I never needed them for problem solving competitions(logic and math), thank you!
I am very good from learning from seeing a example!
-
If you can't figure out what to do when I tell you to use a reference, then it's time to look up that term.
-
Ah my bad I look realy dumb here, I suceeded but I didn't realise I was compiling the wrong thing the whole time sorry!