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

Author Topic: Inherits: Rectangle Shape, cannot call move method?  (Read 2152 times)

0 Members and 1 Guest are viewing this topic.

doingit

  • Newbie
  • *
  • Posts: 17
    • View Profile
Inherits: Rectangle Shape, cannot call move method?
« on: March 08, 2016, 08:34:08 pm »
Hi everyone,

As the title states, I am having issues calling an inherited method "move(10.f,10.f)" from the Rectangle Shape class.
Example below:
    //What we'd could normally do:
    sf::RectangleShape aRectShape;
    aRectShape.move(10.f,10.f);//Works
   
    //In a class that inherits Rectangle Shape:
    this->move(10.f,10.f);//Does not work;
From my understanding, the Rectangle Shape class that I have inherited, also inherits a move from the transformable class. Why am I not allowed to access the move method from Rectangle Shape in its child class that I've created?

Thanks.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: Inherits: Rectangle Shape, cannot call move method?
« Reply #1 on: March 08, 2016, 08:44:54 pm »
Show the definition of the class, and most important, the compiler error that you get.
Laurent Gomila - SFML developer

doingit

  • Newbie
  • *
  • Posts: 17
    • View Profile
Re: Inherits: Rectangle Shape, cannot call move method?
« Reply #2 on: March 08, 2016, 09:14:25 pm »
Sorry, my mistake =D
Sleep deprive caused me to overlook something, a simple c++ error, thanks.

Edit: Solved.

For completeness, it was due to multiple inheritance, and me not properly removing ambiguity.
Basically sf::Rectangle Shape was inheriting the move method from sf::transformable and I from sf::Rectangle Shape.

So the call: sf::RectangleShape::move(/*stuff*/) allowed me to access the move method from sf::transformable.
« Last Edit: March 08, 2016, 09:32:19 pm by doingit »

Hapax

  • Hero Member
  • *****
  • Posts: 3379
  • My number of posts is shown in hexadecimal.
    • View Profile
    • Links
Re: Inherits: Rectangle Shape, cannot call move method?
« Reply #3 on: March 08, 2016, 09:31:16 pm »
As a guess, I'd say that you forgot to add the "public" keyword to your inheritance declaration?
Selba Ward -SFML drawables
Cheese Map -Drawable Layered Tile Map
Kairos -Timing Library
Grambol
 *Hapaxia Links*

 

anything