SFML community forums

Help => Window => Topic started by: danthebeliever on February 07, 2011, 10:11:20 pm

Title: [SOLVED] Having a Window variable in a class
Post by: danthebeliever on February 07, 2011, 10:11:20 pm
Hello,

Is it possible to declare a window variable in a class?

Right now I have

Code: [Select]
class dumbClass{
  sf::Window App;
};


And it gives me errors about NonCopyable. Clearly I am doing something wrong.

edit: I figured out the problem. Doesn't want me to instantiate without it's constructor, so I just made a pointer to the window. (sf::Window * app)
Title: [SOLVED] Having a Window variable in a class
Post by: Laurent on February 07, 2011, 11:27:14 pm
You can have a non-pointer sf::Window member. You did something wrong, but it's not shown in these 2 lines of code.

Can you please post the complete example, and the exact error message?
Title: [SOLVED] Having a Window variable in a class
Post by: Mon ouïe on February 07, 2011, 11:35:10 pm
Just a thought:
Code: [Select]
class dumbClass {
  sf::Window App:
};


is fine. However,
Code: [Select]
dumbClass obj;
obj.App = sf::Window(...);


Would not be, as sf::Window can't be copied (using sf::Window::Open could then solve the problem).
Title: [SOLVED] Having a Window variable in a class
Post by: danthebeliever on February 09, 2011, 12:54:09 am
Thanks Mon, I think that is it.

However, I am fine with pointers! Thanks all, I really appreciate it.