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

Author Topic: setSize error with structure.  (Read 1201 times)

0 Members and 1 Guest are viewing this topic.

magyarosipeter

  • Newbie
  • *
  • Posts: 4
    • View Profile
    • Email
setSize error with structure.
« on: July 08, 2018, 09:53:01 pm »
struct Bat {
    sf::RectangleShape shape();
    int x=360;
    int vx=1;
} batleft, batright;

int main ()
{
     (...)
     batleft.shape.setSize(sf::Vector2f(50, 20))
     batright.shape.setSize(sf::Vector2f(50, 20))
     (...)
}
 

Hey everyone. This code gives me the following error : 'batleft.Bat::shape' does not have class type. Same with the right one. I tried setting the size in the declaration but it gives me even more errors ( expected ')' before numeric constant / expected ';' at end of member decalaration / expected unqualified-id before numeric constant ).
« Last Edit: July 08, 2018, 10:02:39 pm by magyarosipeter »

G.

  • Hero Member
  • *****
  • Posts: 1593
    • View Profile
Re: setSize error with structure.
« Reply #1 on: July 09, 2018, 05:38:00 am »
Quote
struct Bat {
    sf::RectangleShape shape();
You're declaring a function named shape, returning an sf::RectangleShape.
Remove the parentheses to declare a data member named shape of type sf::RectangleShape.
« Last Edit: July 09, 2018, 05:46:56 am by G. »

magyarosipeter

  • Newbie
  • *
  • Posts: 4
    • View Profile
    • Email
Re: setSize error with structure.
« Reply #2 on: July 09, 2018, 11:36:02 am »
Right... bad mistake. Thanks   :D

 

anything