public:void__thiscall SFML C++

Sammy the Wolf 1 Reputation point
2020-12-31T09:22:17.387+00:00

so, first of all, i have problem with memory (i have proof from doctor) and its possible that i forget about something so dont hate me if its something simple, and second, im quite new (i started learning programming 1 and half month ago).

so im currently working on a 2D game with SFML and C++, i made some simple classes etc, here is code for my main:
#include "Game.h"

int main() {  
  
    Game game;  
    game.Run();  
  
    return 0;  
}  

code for Game.h:

#pragma once  
  
#include <iostream>  
#include <SFML/Graphics.hpp>  
#include <SFML/Audio.hpp>  
#include <SFML/Network.hpp>  
#include <SFML/Window.hpp>  
#include <SFML/System.hpp>  
using namespace sf;  
  
class Game {  
	private:  
		CircleShape Player();  
	public:  
		void InitWindow(RenderWindow &window, Event &SfEvent);  
		void Update(CircleShape &Player);  
		void Draw(RenderWindow &window, CircleShape &Player);  
		void Run();  
  
};  

and last, code for my Game.cpp:

#include "Game.h"  
  
void InitWindow(RenderWindow &window, Event &SfEvent) {  
  
	RenderWindow Window(VideoMode(800, 600), "Discord game");  
  
	while (window.isOpen()) {  
  
		while (window.pollEvent(SfEvent)) {  
  
			if (SfEvent.type == Event::Closed) {  
  
				window.close();  
  
			}  
  
			if (Keyboard::isKeyPressed(Keyboard::Escape)) {  
  
				window.close();  
  
			}  
  
		}  
  
	}  
}  
  
void Update(CircleShape &Player) {  
  
	if (Keyboard::isKeyPressed(Keyboard::A)) {  
  
		Player.move(-5.f, 0.f);  
  
	}  
  
	if (Keyboard::isKeyPressed(Keyboard::D)) {  
  
		Player.move(5.f, 0.f);  
  
	}  
  
	if (Keyboard::isKeyPressed(Keyboard::W)) {  
  
		Player.move(0.f, -5.f);  
  
	}  
  
	if (Keyboard::isKeyPressed(Keyboard::S)) {  
  
		Player.move(0.f, 5.f);  
  
	}  
  
}  
  
void Draw(RenderWindow &window, CircleShape &Player) {  
  
	Player.setRadius(50.f);  
	Player.setFillColor(Color::Black);  
  
	window.clear(Color::White);  
	window.draw(Player);  
	window.display();  
  
}  
  
void Run() {  
  
	void InitWindow(RenderWindow & window, Event & SfEvent);  
	void Update(CircleShape &Player);  
	void Draw(RenderWindow &window, CircleShape &Player);  
  
}  

i tried searching for solutions on this on 3 different sites (stack overflow etc) and i didnt find anything that would fix it, the error message is:

Severity	Code	Description	Project	File	Line	Suppression State  
Error	LNK2019	unresolved external symbol "public: void __thiscall Game::Run(void)" (?Run@Game@@QAEXXZ) referenced in function _main	discord game	D:\C++\discord game\discord game\discord game.obj	1	  

any help is welcomed, and sorry that it isnt so long its because i tried to wrote it on stack overflow, i couldnt, i tried to write this on old microsoft QnA and then it send me here so sorry, if someone needs some information i can tell them more

Developer technologies C++
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. RLWA32 49,536 Reputation points
    2020-12-31T09:36:22.827+00:00

    The Game class member functions declared in Game.h need to have their names prefixed with Game:: in their definitions contained in Game.cpp. For example Game::Run, and so forth for the other defined member functions.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.