by declaring Resource r
in every function you create a new instance of the Resource
class every time thus creating many different Resource
objects.
The same goes for the Window w
variable you declare in every function of the class Resource
: each function call will create a new window.
I suggest you to read about Object Oriented Programming and variable scoping.
Also, C++ is not the most friendly language to start learning about Object Oriented Programming.
If you are starting out, I suggest you to switch to a simpler language such as Java or C#.
Good luck.