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

Author Topic: Problems inheriting RectangleShape (new to C++ as well)  (Read 3609 times)

0 Members and 1 Guest are viewing this topic.

Bluesroo

  • Newbie
  • *
  • Posts: 4
    • View Profile
Problems inheriting RectangleShape (new to C++ as well)
« on: February 07, 2014, 04:03:34 am »
I want to preface this by saying that I am making the transition from C to C++, and from vim to Visual C++ 2010, so if this could be better answered by me learning a concept that I'm missing feel free to just say "go learn ___ and come back." I hope I'm not too verbose with this post... With that said, onto the issue:

#pragma once
#include "stdafx.h"

class ShapeWrapper: public sf::RectangleShape
{
        public:
                //Checks that the click was inside of the shape
                bool checkShape(sf::RenderWindow *window)
                {
                        if (sf::Mouse::getPosition(*window).x >= getPosition().x && sf::Mouse::getPosition(*window).x <= (getPosition().x + 100))
                                if (sf::Mouse::getPosition(*window).y >= getPosition().y && sf::Mouse::getPosition(*window).y <= (getPosition().y + 100))
                                        return true;

                        return false;
                }
};

This is a new class that I am trying to make. This member function that I've written is supposed to check that the mouse position is within the bounds of the box drawn on the screen. It worked in an earlier version of the code where it was a regular function, not inside of a class. I would pass in the RenderWindow and the RectangleShape that I was checking instead of doing it from inside of a member function.

Since I've put it into the class I've lost access to all of the other member functions. For example, "getPosition" is underlined in red saying that "identifier 'getPosition' is undefined". But by my novice C++ understanding, it shouldn't be because ShapeWrapper should have inherited it from RectangleShape, correct?

This is the Output when I try to build it in debugging mode (this is the only file in my 6-file project that gives me any errors):
1>------ Build started: Project: circleClicker, Configuration: Debug Win32 ------
1>  smallFunctions.cpp
1>c:\users\joe\documents\visual studio 2010\projects\circleclicker\circleclicker\wrappers.h(4): error C2653: 'sf' : is not a class or namespace name
1>c:\users\joe\documents\visual studio 2010\projects\circleclicker\circleclicker\wrappers.h(5): error C2504: 'RectangleShape' : base class undefined
1>c:\users\joe\documents\visual studio 2010\projects\circleclicker\circleclicker\wrappers.h(8): error C2653: 'sf' : is not a class or namespace name
1>c:\users\joe\documents\visual studio 2010\projects\circleclicker\circleclicker\wrappers.h(8): error C2061: syntax error : identifier 'RenderWindow'
1>c:\users\joe\documents\visual studio 2010\projects\circleclicker\circleclicker\wrappers.h(10): error C2653: 'sf' : is not a class or namespace name
1>c:\users\joe\documents\visual studio 2010\projects\circleclicker\circleclicker\wrappers.h(10): error C2065: 'window' : undeclared identifier
1>c:\users\joe\documents\visual studio 2010\projects\circleclicker\circleclicker\wrappers.h(10): error C2228: left of '.x' must have class/struct/union
1>          type is ''unknown-type''
1>c:\users\joe\documents\visual studio 2010\projects\circleclicker\circleclicker\wrappers.h(10): error C2228: left of '.x' must have class/struct/union
1>          type is ''unknown-type''
1>c:\users\joe\documents\visual studio 2010\projects\circleclicker\circleclicker\wrappers.h(10): error C2653: 'sf' : is not a class or namespace name
1>c:\users\joe\documents\visual studio 2010\projects\circleclicker\circleclicker\wrappers.h(10): error C2065: 'window' : undeclared identifier
1>c:\users\joe\documents\visual studio 2010\projects\circleclicker\circleclicker\wrappers.h(10): error C2228: left of '.x' must have class/struct/union
1>          type is ''unknown-type''
1>c:\users\joe\documents\visual studio 2010\projects\circleclicker\circleclicker\wrappers.h(10): error C2228: left of '.x' must have class/struct/union
1>          type is ''unknown-type''
1>c:\users\joe\documents\visual studio 2010\projects\circleclicker\circleclicker\wrappers.h(10): error C3861: 'getPosition': identifier not found
1>c:\users\joe\documents\visual studio 2010\projects\circleclicker\circleclicker\wrappers.h(10): error C3861: 'getPosition': identifier not found
1>c:\users\joe\documents\visual studio 2010\projects\circleclicker\circleclicker\wrappers.h(10): error C3861: 'getPosition': identifier not found
1>c:\users\joe\documents\visual studio 2010\projects\circleclicker\circleclicker\wrappers.h(10): error C3861: 'getPosition': identifier not found
1>c:\users\joe\documents\visual studio 2010\projects\circleclicker\circleclicker\wrappers.h(11): error C2653: 'sf' : is not a class or namespace name
1>c:\users\joe\documents\visual studio 2010\projects\circleclicker\circleclicker\wrappers.h(11): error C2065: 'window' : undeclared identifier
1>c:\users\joe\documents\visual studio 2010\projects\circleclicker\circleclicker\wrappers.h(11): error C2228: left of '.y' must have class/struct/union
1>          type is ''unknown-type''
1>c:\users\joe\documents\visual studio 2010\projects\circleclicker\circleclicker\wrappers.h(11): error C2228: left of '.y' must have class/struct/union
1>          type is ''unknown-type''
1>c:\users\joe\documents\visual studio 2010\projects\circleclicker\circleclicker\wrappers.h(11): error C2653: 'sf' : is not a class or namespace name
1>c:\users\joe\documents\visual studio 2010\projects\circleclicker\circleclicker\wrappers.h(11): error C2065: 'window' : undeclared identifier
1>c:\users\joe\documents\visual studio 2010\projects\circleclicker\circleclicker\wrappers.h(11): error C2228: left of '.y' must have class/struct/union
1>          type is ''unknown-type''
1>c:\users\joe\documents\visual studio 2010\projects\circleclicker\circleclicker\wrappers.h(11): error C2228: left of '.y' must have class/struct/union
1>          type is ''unknown-type''
1>c:\users\joe\documents\visual studio 2010\projects\circleclicker\circleclicker\wrappers.h(11): error C3861: 'getPosition': identifier not found
1>c:\users\joe\documents\visual studio 2010\projects\circleclicker\circleclicker\wrappers.h(11): error C3861: 'getPosition': identifier not found
1>c:\users\joe\documents\visual studio 2010\projects\circleclicker\circleclicker\wrappers.h(11): error C3861: 'getPosition': identifier not found
1>c:\users\joe\documents\visual studio 2010\projects\circleclicker\circleclicker\wrappers.h(11): error C3861: 'getPosition': identifier not found
1>  game.cpp
1>c:\users\joe\documents\visual studio 2010\projects\circleclicker\circleclicker\wrappers.h(4): error C2653: 'sf' : is not a class or namespace name
1>c:\users\joe\documents\visual studio 2010\projects\circleclicker\circleclicker\wrappers.h(5): error C2504: 'RectangleShape' : base class undefined
1>c:\users\joe\documents\visual studio 2010\projects\circleclicker\circleclicker\wrappers.h(8): error C2653: 'sf' : is not a class or namespace name
1>c:\users\joe\documents\visual studio 2010\projects\circleclicker\circleclicker\wrappers.h(8): error C2061: syntax error : identifier 'RenderWindow'
1>c:\users\joe\documents\visual studio 2010\projects\circleclicker\circleclicker\wrappers.h(10): error C2653: 'sf' : is not a class or namespace name
1>c:\users\joe\documents\visual studio 2010\projects\circleclicker\circleclicker\wrappers.h(10): error C2065: 'window' : undeclared identifier
1>c:\users\joe\documents\visual studio 2010\projects\circleclicker\circleclicker\wrappers.h(10): error C2228: left of '.x' must have class/struct/union
1>          type is ''unknown-type''
1>c:\users\joe\documents\visual studio 2010\projects\circleclicker\circleclicker\wrappers.h(10): error C2228: left of '.x' must have class/struct/union
1>          type is ''unknown-type''
1>c:\users\joe\documents\visual studio 2010\projects\circleclicker\circleclicker\wrappers.h(10): error C2653: 'sf' : is not a class or namespace name
1>c:\users\joe\documents\visual studio 2010\projects\circleclicker\circleclicker\wrappers.h(10): error C2065: 'window' : undeclared identifier
1>c:\users\joe\documents\visual studio 2010\projects\circleclicker\circleclicker\wrappers.h(10): error C2228: left of '.x' must have class/struct/union
1>          type is ''unknown-type''
1>c:\users\joe\documents\visual studio 2010\projects\circleclicker\circleclicker\wrappers.h(10): error C2228: left of '.x' must have class/struct/union
1>          type is ''unknown-type''
1>c:\users\joe\documents\visual studio 2010\projects\circleclicker\circleclicker\wrappers.h(10): error C3861: 'getPosition': identifier not found
1>c:\users\joe\documents\visual studio 2010\projects\circleclicker\circleclicker\wrappers.h(10): error C3861: 'getPosition': identifier not found
1>c:\users\joe\documents\visual studio 2010\projects\circleclicker\circleclicker\wrappers.h(10): error C3861: 'getPosition': identifier not found
1>c:\users\joe\documents\visual studio 2010\projects\circleclicker\circleclicker\wrappers.h(10): error C3861: 'getPosition': identifier not found
1>c:\users\joe\documents\visual studio 2010\projects\circleclicker\circleclicker\wrappers.h(11): error C2653: 'sf' : is not a class or namespace name
1>c:\users\joe\documents\visual studio 2010\projects\circleclicker\circleclicker\wrappers.h(11): error C2065: 'window' : undeclared identifier
1>c:\users\joe\documents\visual studio 2010\projects\circleclicker\circleclicker\wrappers.h(11): error C2228: left of '.y' must have class/struct/union
1>          type is ''unknown-type''
1>c:\users\joe\documents\visual studio 2010\projects\circleclicker\circleclicker\wrappers.h(11): error C2228: left of '.y' must have class/struct/union
1>          type is ''unknown-type''
1>c:\users\joe\documents\visual studio 2010\projects\circleclicker\circleclicker\wrappers.h(11): error C2653: 'sf' : is not a class or namespace name
1>c:\users\joe\documents\visual studio 2010\projects\circleclicker\circleclicker\wrappers.h(11): error C2065: 'window' : undeclared identifier
1>c:\users\joe\documents\visual studio 2010\projects\circleclicker\circleclicker\wrappers.h(11): error C2228: left of '.y' must have class/struct/union
1>          type is ''unknown-type''
1>c:\users\joe\documents\visual studio 2010\projects\circleclicker\circleclicker\wrappers.h(11): error C2228: left of '.y' must have class/struct/union
1>          type is ''unknown-type''
1>c:\users\joe\documents\visual studio 2010\projects\circleclicker\circleclicker\wrappers.h(11): error C3861: 'getPosition': identifier not found
1>c:\users\joe\documents\visual studio 2010\projects\circleclicker\circleclicker\wrappers.h(11): error C3861: 'getPosition': identifier not found
1>c:\users\joe\documents\visual studio 2010\projects\circleclicker\circleclicker\wrappers.h(11): error C3861: 'getPosition': identifier not found
1>c:\users\joe\documents\visual studio 2010\projects\circleclicker\circleclicker\wrappers.h(11): error C3861: 'getPosition': identifier not found
1>c:\users\joe\documents\visual studio 2010\projects\circleclicker\circleclicker\game.cpp(11): error C2065: 'RectangleShapeWrapper' : undeclared identifier
1>c:\users\joe\documents\visual studio 2010\projects\circleclicker\circleclicker\game.cpp(11): error C2146: syntax error : missing ';' before identifier 'circle'
1>c:\users\joe\documents\visual studio 2010\projects\circleclicker\circleclicker\game.cpp(11): error C2065: 'circle' : undeclared identifier
1>c:\users\joe\documents\visual studio 2010\projects\circleclicker\circleclicker\game.cpp(12): error C2065: 'circle' : undeclared identifier
1>c:\users\joe\documents\visual studio 2010\projects\circleclicker\circleclicker\game.cpp(12): error C2228: left of '.setSize' must have class/struct/union
1>          type is ''unknown-type''
1>c:\users\joe\documents\visual studio 2010\projects\circleclicker\circleclicker\game.cpp(13): error C2065: 'circle' : undeclared identifier
1>c:\users\joe\documents\visual studio 2010\projects\circleclicker\circleclicker\game.cpp(13): error C2228: left of '.setOrigin' must have class/struct/union
1>          type is ''unknown-type''
1>c:\users\joe\documents\visual studio 2010\projects\circleclicker\circleclicker\game.cpp(14): error C2065: 'circle' : undeclared identifier
1>c:\users\joe\documents\visual studio 2010\projects\circleclicker\circleclicker\game.cpp(14): error C2228: left of '.setPosition' must have class/struct/union
1>          type is ''unknown-type''
1>c:\users\joe\documents\visual studio 2010\projects\circleclicker\circleclicker\game.cpp(34): error C2065: 'circle' : undeclared identifier
1>c:\users\joe\documents\visual studio 2010\projects\circleclicker\circleclicker\game.cpp(34): error C3861: 'checkShape': identifier not found
1>c:\users\joe\documents\visual studio 2010\projects\circleclicker\circleclicker\game.cpp(36): error C2065: 'circle' : undeclared identifier
1>c:\users\joe\documents\visual studio 2010\projects\circleclicker\circleclicker\game.cpp(36): error C2228: left of '.setPosition' must have class/struct/union
1>          type is ''unknown-type''
1>c:\users\joe\documents\visual studio 2010\projects\circleclicker\circleclicker\game.cpp(65): error C2065: 'circle' : undeclared identifier
1>  endOfGame.cpp
1>c:\users\joe\documents\visual studio 2010\projects\circleclicker\circleclicker\wrappers.h(4): error C2653: 'sf' : is not a class or namespace name
1>c:\users\joe\documents\visual studio 2010\projects\circleclicker\circleclicker\wrappers.h(5): error C2504: 'RectangleShape' : base class undefined
1>c:\users\joe\documents\visual studio 2010\projects\circleclicker\circleclicker\wrappers.h(8): error C2653: 'sf' : is not a class or namespace name
1>c:\users\joe\documents\visual studio 2010\projects\circleclicker\circleclicker\wrappers.h(8): error C2061: syntax error : identifier 'RenderWindow'
1>c:\users\joe\documents\visual studio 2010\projects\circleclicker\circleclicker\wrappers.h(10): error C2653: 'sf' : is not a class or namespace name
1>c:\users\joe\documents\visual studio 2010\projects\circleclicker\circleclicker\wrappers.h(10): error C2065: 'window' : undeclared identifier
1>c:\users\joe\documents\visual studio 2010\projects\circleclicker\circleclicker\wrappers.h(10): error C2228: left of '.x' must have class/struct/union
1>          type is ''unknown-type''
1>c:\users\joe\documents\visual studio 2010\projects\circleclicker\circleclicker\wrappers.h(10): error C2228: left of '.x' must have class/struct/union
1>          type is ''unknown-type''
1>c:\users\joe\documents\visual studio 2010\projects\circleclicker\circleclicker\wrappers.h(10): error C2653: 'sf' : is not a class or namespace name
1>c:\users\joe\documents\visual studio 2010\projects\circleclicker\circleclicker\wrappers.h(10): error C2065: 'window' : undeclared identifier
1>c:\users\joe\documents\visual studio 2010\projects\circleclicker\circleclicker\wrappers.h(10): error C2228: left of '.x' must have class/struct/union
1>          type is ''unknown-type''
1>c:\users\joe\documents\visual studio 2010\projects\circleclicker\circleclicker\wrappers.h(10): error C2228: left of '.x' must have class/struct/union
1>          type is ''unknown-type''
1>c:\users\joe\documents\visual studio 2010\projects\circleclicker\circleclicker\wrappers.h(10): error C3861: 'getPosition': identifier not found
1>c:\users\joe\documents\visual studio 2010\projects\circleclicker\circleclicker\wrappers.h(10): error C3861: 'getPosition': identifier not found
1>c:\users\joe\documents\visual studio 2010\projects\circleclicker\circleclicker\wrappers.h(10): error C3861: 'getPosition': identifier not found
1>c:\users\joe\documents\visual studio 2010\projects\circleclicker\circleclicker\wrappers.h(10): error C3861: 'getPosition': identifier not found
1>c:\users\joe\documents\visual studio 2010\projects\circleclicker\circleclicker\wrappers.h(11): error C2653: 'sf' : is not a class or namespace name
1>c:\users\joe\documents\visual studio 2010\projects\circleclicker\circleclicker\wrappers.h(11): error C2065: 'window' : undeclared identifier
1>c:\users\joe\documents\visual studio 2010\projects\circleclicker\circleclicker\wrappers.h(11): error C2228: left of '.y' must have class/struct/union
1>          type is ''unknown-type''
1>c:\users\joe\documents\visual studio 2010\projects\circleclicker\circleclicker\wrappers.h(11): error C2228: left of '.y' must have class/struct/union
1>          type is ''unknown-type''
1>c:\users\joe\documents\visual studio 2010\projects\circleclicker\circleclicker\wrappers.h(11): error C2653: 'sf' : is not a class or namespace name
1>c:\users\joe\documents\visual studio 2010\projects\circleclicker\circleclicker\wrappers.h(11): error C2065: 'window' : undeclared identifier
1>c:\users\joe\documents\visual studio 2010\projects\circleclicker\circleclicker\wrappers.h(11): error C2228: left of '.y' must have class/struct/union
1>          type is ''unknown-type''
1>c:\users\joe\documents\visual studio 2010\projects\circleclicker\circleclicker\wrappers.h(11): error C2228: left of '.y' must have class/struct/union
1>          type is ''unknown-type''
1>c:\users\joe\documents\visual studio 2010\projects\circleclicker\circleclicker\wrappers.h(11): error C3861: 'getPosition': identifier not found
1>c:\users\joe\documents\visual studio 2010\projects\circleclicker\circleclicker\wrappers.h(11): error C3861: 'getPosition': identifier not found
1>c:\users\joe\documents\visual studio 2010\projects\circleclicker\circleclicker\wrappers.h(11): error C3861: 'getPosition': identifier not found
1>c:\users\joe\documents\visual studio 2010\projects\circleclicker\circleclicker\wrappers.h(11): error C3861: 'getPosition': identifier not found
1>  circleClicker.cpp
1>c:\users\joe\documents\visual studio 2010\projects\circleclicker\circleclicker\wrappers.h(4): error C2653: 'sf' : is not a class or namespace name
1>c:\users\joe\documents\visual studio 2010\projects\circleclicker\circleclicker\wrappers.h(5): error C2504: 'RectangleShape' : base class undefined
1>c:\users\joe\documents\visual studio 2010\projects\circleclicker\circleclicker\wrappers.h(8): error C2653: 'sf' : is not a class or namespace name
1>c:\users\joe\documents\visual studio 2010\projects\circleclicker\circleclicker\wrappers.h(8): error C2061: syntax error : identifier 'RenderWindow'
1>c:\users\joe\documents\visual studio 2010\projects\circleclicker\circleclicker\wrappers.h(10): error C2653: 'sf' : is not a class or namespace name
1>c:\users\joe\documents\visual studio 2010\projects\circleclicker\circleclicker\wrappers.h(10): error C2065: 'window' : undeclared identifier
1>c:\users\joe\documents\visual studio 2010\projects\circleclicker\circleclicker\wrappers.h(10): error C2228: left of '.x' must have class/struct/union
1>          type is ''unknown-type''
1>c:\users\joe\documents\visual studio 2010\projects\circleclicker\circleclicker\wrappers.h(10): error C2228: left of '.x' must have class/struct/union
1>          type is ''unknown-type''
1>c:\users\joe\documents\visual studio 2010\projects\circleclicker\circleclicker\wrappers.h(10): error C2653: 'sf' : is not a class or namespace name
1>c:\users\joe\documents\visual studio 2010\projects\circleclicker\circleclicker\wrappers.h(10): error C2065: 'window' : undeclared identifier
1>c:\users\joe\documents\visual studio 2010\projects\circleclicker\circleclicker\wrappers.h(10): error C2228: left of '.x' must have class/struct/union
1>          type is ''unknown-type''
1>c:\users\joe\documents\visual studio 2010\projects\circleclicker\circleclicker\wrappers.h(10): error C2228: left of '.x' must have class/struct/union
1>          type is ''unknown-type''
1>c:\users\joe\documents\visual studio 2010\projects\circleclicker\circleclicker\wrappers.h(10): error C3861: 'getPosition': identifier not found
1>c:\users\joe\documents\visual studio 2010\projects\circleclicker\circleclicker\wrappers.h(10): error C3861: 'getPosition': identifier not found
1>c:\users\joe\documents\visual studio 2010\projects\circleclicker\circleclicker\wrappers.h(10): error C3861: 'getPosition': identifier not found
1>c:\users\joe\documents\visual studio 2010\projects\circleclicker\circleclicker\wrappers.h(10): error C3861: 'getPosition': identifier not found
1>c:\users\joe\documents\visual studio 2010\projects\circleclicker\circleclicker\wrappers.h(11): error C2653: 'sf' : is not a class or namespace name
1>c:\users\joe\documents\visual studio 2010\projects\circleclicker\circleclicker\wrappers.h(11): error C2065: 'window' : undeclared identifier
1>c:\users\joe\documents\visual studio 2010\projects\circleclicker\circleclicker\wrappers.h(11): error C2228: left of '.y' must have class/struct/union
1>          type is ''unknown-type''
1>c:\users\joe\documents\visual studio 2010\projects\circleclicker\circleclicker\wrappers.h(11): error C2228: left of '.y' must have class/struct/union
1>          type is ''unknown-type''
1>c:\users\joe\documents\visual studio 2010\projects\circleclicker\circleclicker\wrappers.h(11): error C2653: 'sf' : is not a class or namespace name
1>c:\users\joe\documents\visual studio 2010\projects\circleclicker\circleclicker\wrappers.h(11): error C2065: 'window' : undeclared identifier
1>c:\users\joe\documents\visual studio 2010\projects\circleclicker\circleclicker\wrappers.h(11): error C2228: left of '.y' must have class/struct/union
1>          type is ''unknown-type''
1>c:\users\joe\documents\visual studio 2010\projects\circleclicker\circleclicker\wrappers.h(11): error C2228: left of '.y' must have class/struct/union
1>          type is ''unknown-type''
1>c:\users\joe\documents\visual studio 2010\projects\circleclicker\circleclicker\wrappers.h(11): error C3861: 'getPosition': identifier not found
1>c:\users\joe\documents\visual studio 2010\projects\circleclicker\circleclicker\wrappers.h(11): error C3861: 'getPosition': identifier not found
1>c:\users\joe\documents\visual studio 2010\projects\circleclicker\circleclicker\wrappers.h(11): error C3861: 'getPosition': identifier not found
1>c:\users\joe\documents\visual studio 2010\projects\circleclicker\circleclicker\wrappers.h(11): error C3861: 'getPosition': identifier not found
1>c:\users\joe\documents\visual studio 2010\projects\circleclicker\circleclicker\circleclicker.cpp(9): warning C4244: 'argument' : conversion from 'time_t' to 'unsigned int', possible loss of data
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

I've tried using
this->getPosition()
as well, but I'm getting the same issue. I have a feeling it is an issue with how I've included my headers, because it doesn't even recognize
sf
as a namespace. Can someone point me in the right direction here? It would be greatly appreciated.

eigenbom

  • Full Member
  • ***
  • Posts: 228
    • View Profile
Re: Problems inheriting RectangleShape (new to C++ as well)
« Reply #1 on: February 07, 2014, 04:10:41 am »
The first line in the log tells you the problem

Code: [Select]
wrappers.h(4): error C2653: 'sf' : is not a class or namespace name

It doesn't know what sf is so include the graphics module before your class definition.

Code: [Select]
#include <SFML/Graphics.hpp>

Bluesroo

  • Newbie
  • *
  • Posts: 4
    • View Profile
Re: Problems inheriting RectangleShape (new to C++ as well)
« Reply #2 on: February 07, 2014, 04:12:45 am »
I included it in stdafx.h so I figured it would carry over... I feel like and idiot. Oh well, it worked when I put it there! Thank you.

eigenbom

  • Full Member
  • ***
  • Posts: 228
    • View Profile
Re: Problems inheriting RectangleShape (new to C++ as well)
« Reply #3 on: February 07, 2014, 04:41:17 am »
My guess is that you also have a "#pragma once" in your stdafx.h, which means that it'll only get included once per compilation unit.

I recommend that you explicitly include any headers you need in each module where you need them, rather than bundling them all in stdafx.h. It makes it very clear which modules depend on what, and in some cases you can simply forward declare instead. I would also disable precompiled headers and get rid of stdafx.h for now.

And don't worry about feeling like an idiot, one of the humps to C++ is learning which error messages are spot on and which ones are misleading. :P
« Last Edit: February 07, 2014, 04:43:42 am by eigenbom »

wintertime

  • Sr. Member
  • ****
  • Posts: 255
    • View Profile
Re: Problems inheriting RectangleShape (new to C++ as well)
« Reply #4 on: February 07, 2014, 01:28:08 pm »
There is no need to inherit from RectangleShape in that example, you could just use a free function. Generally it is better to favor composition over inheritance.
I would also not give it a pointer to the window or directly ask for the mouse position so many times. You can use the events from SFML, use the position as an argument and only check it when you got informed of a change.

 

anything