Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: [SOLVED] Having a Window variable in a class  (Read 1328 times)

0 Members and 1 Guest are viewing this topic.

danthebeliever

  • Newbie
  • *
  • Posts: 10
    • View Profile
[SOLVED] Having a Window variable in a class
« 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)

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
[SOLVED] Having a Window variable in a class
« Reply #1 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?
Laurent Gomila - SFML developer

Mon ouïe

  • Newbie
  • *
  • Posts: 27
    • View Profile
[SOLVED] Having a Window variable in a class
« Reply #2 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).

danthebeliever

  • Newbie
  • *
  • Posts: 10
    • View Profile
[SOLVED] Having a Window variable in a class
« Reply #3 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.

 

anything