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

Author Topic: No matching member function for call to 'draw'  (Read 128 times)

0 Members and 1 Guest are viewing this topic.

blueoyster

  • Newbie
  • *
  • Posts: 2
    • View Profile
No matching member function for call to 'draw'
« on: January 05, 2025, 10:08:02 pm »
New to c++ and sfml,
Tried to implement my circle into a separate header and class file.
.draw() doesnt accept that my circle.shape is a drawable.
tho It seems to work with sf::RectangleShape.
I did the almost exact same wtith RectShape and that draws it no problem.

header file ; https://pastebin.com/n7enWda9

circle class: https://pastebin.com/Pq0cAXfn

main file (demo, essentially) : https://pastebin.com/mdDULJfQ

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11072
    • View Profile
    • development blog
    • Email
Re: No matching member function for call to 'draw'
« Reply #1 on: January 05, 2025, 10:49:15 pm »
What's the full/complete error?
Official FAQ: https://www.sfml-dev.org/faq/
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

blueoyster

  • Newbie
  • *
  • Posts: 2
    • View Profile
Re: No matching member function for call to 'draw'
« Reply #2 on: January 06, 2025, 09:27:40 pm »
FAILED: _deps/sfml-build/src/SFML/Graphics/CMakeFiles/sfml-graphics.dir/RenderTarget.cpp.obj
C:\MinGW\bin\c++.exe -DSFML_STATIC -DSTBI_FAILURE_USERMSG -IC:/PATH/cmake-build-debug/_deps/sfml-src/include -IC:/PATH/cmake-build-debug/_deps/sfml-src/src -isystem C:/PATH/cmake-build-debug/_deps/sfml-src/extlibs/headers/stb_image -isystem C:/PATH/cmake-build-debug/_deps/sfml-src/extlibs/headers/glad/include -isystem C:/PATH/cmake-build-debug/_deps/sfml-src/extlibs/headers/freetype2 -g -fdiagnostics-color=always  -Wall -Wextra -Wshadow -Wnon-virtual-dtor -Wcast-align -Wunused -Woverloaded-virtual -Wconversion -Wsign-conversion -Wdouble-promotion -Wformat=2 -Wnull-dereference -Wold-style-cast -Wpedantic -Wmisleading-indentation -Wduplicated-cond -Wlogical-op -MD -MT _deps/sfml-build/src/SFML/Graphics/CMakeFiles/sfml-graphics.dir/RenderTarget.cpp.obj -MF _deps\sfml-build\src\SFML\Graphics\CMakeFiles\sfml-graphics.dir\RenderTarget.cpp.obj.d -o _deps/sfml-build/src/SFML/Graphics/CMakeFiles/sfml-graphics.dir/RenderTarget.cpp.obj -c C:/PATH/cmake-build-debug/_deps/sfml-src/src/SFML/Graphics/RenderTarget.cpp
In file included from C:/PATH/cmake-build-debug/_deps/sfml-src/include/SFML/Graphics.hpp:46:0,
                 from c:\users\esadk\onedrive\desktop\programming\physicsengine\circle.h:7,
                 from C:/PATH/cmake-build-debug/_deps/sfml-src/include/SFML/Graphics/RenderTarget.hpp:41,
                 from C:/PATH/cmake-build-debug/_deps/sfml-src/src/SFML/Graphics/RenderTarget.cpp:28:
C:/PATH/cmake-build-debug/_deps/sfml-src/include/SFML/Graphics/RenderTexture.hpp:48:48: error: invalid use of incomplete type 'class sf::RenderTarget'
 class SFML_GRAPHICS_API RenderTexture : public RenderTarget
                                                ^~~~~~~~~~~~
In file included from C:/PATH/cmake-build-debug/_deps/sfml-src/include/SFML/Graphics/Shape.hpp:32:0,
                 from C:/PATH/cmake-build-debug/_deps/sfml-src/include/SFML/Graphics/CircleShape.hpp:32,
                 from C:/PATH/cmake-build-debug/_deps/sfml-src/include/SFML/Graphics.hpp:34,
                 from c:\users\esadk\onedrive\desktop\programming\physicsengine\circle.h:7,
                 from C:/PATH/cmake-build-debug/_deps/sfml-src/include/SFML/Graphics/RenderTarget.hpp:41,
                 from C:/PATH/cmake-build-debug/_deps/sfml-src/src/SFML/Graphics/RenderTarget.cpp:28:
C:/PATH/cmake-build-debug/_deps/sfml-src/include/SFML/Graphics/Drawable.hpp:37:7: note: forward declaration of 'class sf::RenderTarget'
 class RenderTarget;
       ^~~~~~~~~~~~
In file included from C:/PATH/cmake-build-debug/_deps/sfml-src/include/SFML/Graphics.hpp:47:0,
                 from c:\users\esadk\onedrive\desktop\programming\physicsengine\circle.h:7,
                 from C:/PATH/cmake-build-debug/_deps/sfml-src/include/SFML/Graphics/RenderTarget.hpp:41,
                 from C:/PATH/cmake-build-debug/_deps/sfml-src/src/SFML/Graphics/RenderTarget.cpp:28:
C:/PATH/cmake-build-debug/_deps/sfml-src/include/SFML/Graphics/RenderWindow.hpp:44:62: error: invalid use of incomplete type 'class sf::RenderTarget'
 class SFML_GRAPHICS_API RenderWindow : public Window, public RenderTarget
                                                              ^~~~~~~~~~~~
In file included from C:/PATH/cmake-build-debug/_deps/sfml-src/include/SFML/Graphics/Shape.hpp:32:0,
                 from C:/PATH/cmake-build-debug/_deps/sfml-src/include/SFML/Graphics/CircleShape.hpp:32,
                 from C:/PATH/cmake-build-debug/_deps/sfml-src/include/SFML/Graphics.hpp:34,
                 from c:\users\esadk\onedrive\desktop\programming\physicsengine\circle.h:7,
                 from C:/PATH/cmake-build-debug/_deps/sfml-src/include/SFML/Graphics/RenderTarget.hpp:41,
                 from C:/PATH/cmake-build-debug/_deps/sfml-src/src/SFML/Graphics/RenderTarget.cpp:28:
C:/PATH/cmake-build-debug/_deps/sfml-src/include/SFML/Graphics/Drawable.hpp:37:7: note: forward declaration of 'class sf::RenderTarget'
 class RenderTarget;
       ^~~~~~~~~~~~
C:/PATH/cmake-build-debug/_deps/sfml-src/src/SFML/Graphics/RenderTarget.cpp: In member function 'void sf::RenderTarget::draw(sf::RectangleShape, const sf::RenderStates&)':
C:/PATH/cmake-build-debug/_deps/sfml-src/src/SFML/Graphics/RenderTarget.cpp:268:32: error: 'virtual void sf::Shape::draw(sf::RenderTarget&, sf::RenderStates) const' is private within this context
     drawable.draw(*this, states);
                                ^
In file included from C:/PATH/cmake-build-debug/_deps/sfml-src/include/SFML/Graphics/CircleShape.hpp:32:0,
                 from C:/PATH/cmake-build-debug/_deps/sfml-src/include/SFML/Graphics.hpp:34,
                 from c:\users\esadk\onedrive\desktop\programming\physicsengine\circle.h:7,
                 from C:/PATH/cmake-build-debug/_deps/sfml-src/include/SFML/Graphics/RenderTarget.hpp:41,
                 from C:/PATH/cmake-build-debug/_deps/sfml-src/src/SFML/Graphics/RenderTarget.cpp:28:
C:/PATH/cmake-build-debug/_deps/sfml-src/include/SFML/Graphics/Shape.hpp:277:18: note: declared private here
     virtual void draw(RenderTarget& target, RenderStates states) const;
                  ^~~~
ninja: build stopped: subcommand failed.

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11072
    • View Profile
    • development blog
    • Email
Re: No matching member function for call to 'draw'
« Reply #3 on: January 07, 2025, 08:47:50 am »
It errors within the SFML headers. Hmm.

What's your version of MinGW that you're using?
Official FAQ: https://www.sfml-dev.org/faq/
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

 

anything