conversion from 'std::unique_ptr<derived, std::default_delete >' to non-scalar type 'std::unique_ptr'...
I am currently making an StateMachine for a game using several ressources on the web.
However, my issue came when I try to create a State to put it in the StateMachine.
The error is in the StateGameMenu.cpp, in sendConnexion.
StateGameMenu.h
#ifndef STATEGAMEMENU_H
#define STATEGAMEMENU_H
#include <TGUI/TGUI.hpp>
#include <SFML/Graphics.hpp>
#include <SFML/Network.hpp>
#include <memory>
#include <thread>
#include "Log.h"
#include "Client.h"
#include "Personnage.h"
#include "State.hpp"
class StateMachine;
class StateGameMenu : public State
{
public:
StateGameMenu(Context& context);
virtual ~StateGameMenu();
protected:
void sendConnexion(tgui::EditBox::Ptr username, tgui::EditBox::Ptr password);
void loadGUI();
private:
};
#endif // STATEGAMEMENU_H
StateGameMenu.cpp, where my error is.
#include "StateGameMenu.h"
#include "StateGamePlay.h"
#include "StateMachine.h"
StateGameMenu::StateGameMenu(Context& context) : State(context)
{
//ctor
}
void StateGameMenu::sendConnexion(tgui::EditBox::Ptr username, tgui::EditBox::Ptr password)
{
m_context.Client->connexion(username->getText().toAnsiString(), password->getText().toAnsiString());
if(m_context.Client->estConnecte())
{
///The line below is the line triggering an error.
std::unique_ptr<State> temp = StateMachine::build<StateGamePlay>(m_context); ///The problem is here.
m_context.Machine->askPush(std::move(temp), true);
}
}
void StateGameMenu::loadGUI()
{
/* Some GUI Stuff ... */
button->connect("pressed", StateGameMenu::sendConnexion, this, editBoxUsername, editBoxPassword);
}
StateGameMenu::~StateGameMenu(){}
The error is :
conversion from 'std::unique_ptr<StateGamePlay, std::default_delete<StateGamePlay> >' to non-scalar type 'std::unique_ptr<State>' requested|
It's actually really diffcult for me to understand why the output of the function "build" isn't simply a "std::unique_ptr".
StateGamePlay.h
#ifndef STATEGAMEPLAY_H
#define STATEGAMEPLAY_H
#include "State.hpp"
class StateMachine;
class StateGamePlay : State
{
public:
StateGamePlay(Context& context);
virtual ~StateGamePlay();
protected:
private:
};
#endif // STATEGAMEPLAY_H
StateGamePlay.cpp
#include "StateGamePlay.h"
#include "StateMachine.h"
StateGamePlay::StateGamePlay(Context& context) : State(context)
{
//ctor
}
For more informations :
StateMachine.h
#ifndef STATEMACHINE_H
#define STATEMACHINE_H
#include <SFML/Graphics.hpp>
#include <stack>
#include <memory>
#include "Log.h"
#include "Context.h"
class State;
class StateMachine
{
public:
typedef std::unique_ptr<State> StatePtr;
StateMachine();
void askPush(StatePtr state, bool isReplacing = true);
void askPop();
template <typename T>
static std::unique_ptr<T> build( Context& context );
void processStateChanging();
virtual ~StateMachine();
protected:
void push();
void pop();
void resume();
void pause();
void modifyState();
std::stack<StatePtr> m_States;
bool m_isReplacing;
bool m_isChanging;
bool m_isDeleting;
StatePtr m_FutureChangingState;
private:
};
#include "State.hpp"
template <typename T>
std::unique_ptr<T> StateMachine::build( Context& context )
{
//return std::unique_ptr<T>( new T(context) );
return std::make_unique<T>( context );
}
#endif // STATEMACHINE_H
It seems like the problem is directly linked to the template function, but I don't see anything wrong with that part, and the call seems to be written correctly.
State.hpp
#ifndef STATE_H
#define STATE_H
#include <SFML/Graphics.hpp>
#include <TGUI/TGUI.hpp>
#include <memory>
#include "Client.h"
#include "Context.h"
class StateMachine;
class State
{
public:
State(Context& context);
State ( const State& ) = delete;
State& operator= ( const State& ) = delete;
void pause() {inPause = true;};
void resume() {inPause = false;};
virtual ~State();
protected:
bool inPause;
Context m_context;
private:
};
#endif // STATE_H
Context.h
#ifndef CONTEXT_H_INCLUDED
#define CONTEXT_H_INCLUDED
#include <SFML/Graphics.hpp>
#include <TGUI/TGUI.hpp>
#include <memory>
#include "Client.h"
class StateMachine;
struct Context
{
typedef std::shared_ptr<sf::RenderWindow> WindowPtr;
typedef std::shared_ptr<StateMachine> MachinePtr;
typedef std::shared_ptr<tgui::Gui> GuiPtr;
typedef std::shared_ptr<Client> ClientPtr;
Context(WindowPtr window, MachinePtr machine, GuiPtr gui, ClientPtr client);
WindowPtr Window;
MachinePtr Machine;
GuiPtr Gui;
ClientPtr Client;
};
Context::Context(WindowPtr window, MachinePtr machine, GuiPtr gui, ClientPtr client) :
Window(window), Machine(machine), Gui(gui), Client(client)
{ }
#endif // CONTEXT_H_INCLUDED
To finish, one of my main ressource to write that part is https://github.com/eXpl0it3r/SmallGameEngine/tree/master/ by eXpl0it3r (which is a change of an other code).
In this code, the way the State is given to the StateMachine is really similar to mine, however it doesn't work in my case and I don't know why.
And yes, I could clone my code on this one but I prefer to do that on my own.
I hope my post isn't too long and fuzzy as I am myself really confused. (And I didn't find anything to answer my question.)
Thank you for reading this whole post and for your time anyway ! (And sorry for my poor english).
c++ state c++17 unique-ptr
closed as off-topic by n.m., user4581301, S.M., P.W, llllllllll Jan 3 at 6:48
This question appears to be off-topic. The users who voted to close gave this specific reason:
- "Questions seeking debugging help ("why isn't this code working?") must include the desired behavior, a specific problem or error and the shortest code necessary to reproduce it in the question itself. Questions without a clear problem statement are not useful to other readers. See: How to create a Minimal, Complete, and Verifiable example." – n.m., user4581301, S.M., P.W, llllllllll
If this question can be reworded to fit the rules in the help center, please edit the question.
add a comment |
I am currently making an StateMachine for a game using several ressources on the web.
However, my issue came when I try to create a State to put it in the StateMachine.
The error is in the StateGameMenu.cpp, in sendConnexion.
StateGameMenu.h
#ifndef STATEGAMEMENU_H
#define STATEGAMEMENU_H
#include <TGUI/TGUI.hpp>
#include <SFML/Graphics.hpp>
#include <SFML/Network.hpp>
#include <memory>
#include <thread>
#include "Log.h"
#include "Client.h"
#include "Personnage.h"
#include "State.hpp"
class StateMachine;
class StateGameMenu : public State
{
public:
StateGameMenu(Context& context);
virtual ~StateGameMenu();
protected:
void sendConnexion(tgui::EditBox::Ptr username, tgui::EditBox::Ptr password);
void loadGUI();
private:
};
#endif // STATEGAMEMENU_H
StateGameMenu.cpp, where my error is.
#include "StateGameMenu.h"
#include "StateGamePlay.h"
#include "StateMachine.h"
StateGameMenu::StateGameMenu(Context& context) : State(context)
{
//ctor
}
void StateGameMenu::sendConnexion(tgui::EditBox::Ptr username, tgui::EditBox::Ptr password)
{
m_context.Client->connexion(username->getText().toAnsiString(), password->getText().toAnsiString());
if(m_context.Client->estConnecte())
{
///The line below is the line triggering an error.
std::unique_ptr<State> temp = StateMachine::build<StateGamePlay>(m_context); ///The problem is here.
m_context.Machine->askPush(std::move(temp), true);
}
}
void StateGameMenu::loadGUI()
{
/* Some GUI Stuff ... */
button->connect("pressed", StateGameMenu::sendConnexion, this, editBoxUsername, editBoxPassword);
}
StateGameMenu::~StateGameMenu(){}
The error is :
conversion from 'std::unique_ptr<StateGamePlay, std::default_delete<StateGamePlay> >' to non-scalar type 'std::unique_ptr<State>' requested|
It's actually really diffcult for me to understand why the output of the function "build" isn't simply a "std::unique_ptr".
StateGamePlay.h
#ifndef STATEGAMEPLAY_H
#define STATEGAMEPLAY_H
#include "State.hpp"
class StateMachine;
class StateGamePlay : State
{
public:
StateGamePlay(Context& context);
virtual ~StateGamePlay();
protected:
private:
};
#endif // STATEGAMEPLAY_H
StateGamePlay.cpp
#include "StateGamePlay.h"
#include "StateMachine.h"
StateGamePlay::StateGamePlay(Context& context) : State(context)
{
//ctor
}
For more informations :
StateMachine.h
#ifndef STATEMACHINE_H
#define STATEMACHINE_H
#include <SFML/Graphics.hpp>
#include <stack>
#include <memory>
#include "Log.h"
#include "Context.h"
class State;
class StateMachine
{
public:
typedef std::unique_ptr<State> StatePtr;
StateMachine();
void askPush(StatePtr state, bool isReplacing = true);
void askPop();
template <typename T>
static std::unique_ptr<T> build( Context& context );
void processStateChanging();
virtual ~StateMachine();
protected:
void push();
void pop();
void resume();
void pause();
void modifyState();
std::stack<StatePtr> m_States;
bool m_isReplacing;
bool m_isChanging;
bool m_isDeleting;
StatePtr m_FutureChangingState;
private:
};
#include "State.hpp"
template <typename T>
std::unique_ptr<T> StateMachine::build( Context& context )
{
//return std::unique_ptr<T>( new T(context) );
return std::make_unique<T>( context );
}
#endif // STATEMACHINE_H
It seems like the problem is directly linked to the template function, but I don't see anything wrong with that part, and the call seems to be written correctly.
State.hpp
#ifndef STATE_H
#define STATE_H
#include <SFML/Graphics.hpp>
#include <TGUI/TGUI.hpp>
#include <memory>
#include "Client.h"
#include "Context.h"
class StateMachine;
class State
{
public:
State(Context& context);
State ( const State& ) = delete;
State& operator= ( const State& ) = delete;
void pause() {inPause = true;};
void resume() {inPause = false;};
virtual ~State();
protected:
bool inPause;
Context m_context;
private:
};
#endif // STATE_H
Context.h
#ifndef CONTEXT_H_INCLUDED
#define CONTEXT_H_INCLUDED
#include <SFML/Graphics.hpp>
#include <TGUI/TGUI.hpp>
#include <memory>
#include "Client.h"
class StateMachine;
struct Context
{
typedef std::shared_ptr<sf::RenderWindow> WindowPtr;
typedef std::shared_ptr<StateMachine> MachinePtr;
typedef std::shared_ptr<tgui::Gui> GuiPtr;
typedef std::shared_ptr<Client> ClientPtr;
Context(WindowPtr window, MachinePtr machine, GuiPtr gui, ClientPtr client);
WindowPtr Window;
MachinePtr Machine;
GuiPtr Gui;
ClientPtr Client;
};
Context::Context(WindowPtr window, MachinePtr machine, GuiPtr gui, ClientPtr client) :
Window(window), Machine(machine), Gui(gui), Client(client)
{ }
#endif // CONTEXT_H_INCLUDED
To finish, one of my main ressource to write that part is https://github.com/eXpl0it3r/SmallGameEngine/tree/master/ by eXpl0it3r (which is a change of an other code).
In this code, the way the State is given to the StateMachine is really similar to mine, however it doesn't work in my case and I don't know why.
And yes, I could clone my code on this one but I prefer to do that on my own.
I hope my post isn't too long and fuzzy as I am myself really confused. (And I didn't find anything to answer my question.)
Thank you for reading this whole post and for your time anyway ! (And sorry for my poor english).
c++ state c++17 unique-ptr
closed as off-topic by n.m., user4581301, S.M., P.W, llllllllll Jan 3 at 6:48
This question appears to be off-topic. The users who voted to close gave this specific reason:
- "Questions seeking debugging help ("why isn't this code working?") must include the desired behavior, a specific problem or error and the shortest code necessary to reproduce it in the question itself. Questions without a clear problem statement are not useful to other readers. See: How to create a Minimal, Complete, and Verifiable example." – n.m., user4581301, S.M., P.W, llllllllll
If this question can be reworded to fit the rules in the help center, please edit the question.
The error message refersStateGamePlay
. What isStateGamePlay
? IMHO too much code in the question and the important part is missing. Learn how to ask questions: Minimal, Complete, and Verifiable example
– S.M.
Jan 3 at 5:54
2
At the point where you request the conversion, the derived class is probably forward-declared and nothing is known about its base classes. We can't tell for sure becase you've chosen to omit the content of StateGamePlay.h. the only other relevant file beside that with the error.
– n.m.
Jan 3 at 6:00
Thank you for your answers. For me, I through it was obvious but it's stupid since I can miss an error. I edit my post to add the StateGamePlay.h and .cpp and I took off some useless information. And I try to find an issue with the order of the declarations but I miss it.
– TagXy
Jan 3 at 6:35
add a comment |
I am currently making an StateMachine for a game using several ressources on the web.
However, my issue came when I try to create a State to put it in the StateMachine.
The error is in the StateGameMenu.cpp, in sendConnexion.
StateGameMenu.h
#ifndef STATEGAMEMENU_H
#define STATEGAMEMENU_H
#include <TGUI/TGUI.hpp>
#include <SFML/Graphics.hpp>
#include <SFML/Network.hpp>
#include <memory>
#include <thread>
#include "Log.h"
#include "Client.h"
#include "Personnage.h"
#include "State.hpp"
class StateMachine;
class StateGameMenu : public State
{
public:
StateGameMenu(Context& context);
virtual ~StateGameMenu();
protected:
void sendConnexion(tgui::EditBox::Ptr username, tgui::EditBox::Ptr password);
void loadGUI();
private:
};
#endif // STATEGAMEMENU_H
StateGameMenu.cpp, where my error is.
#include "StateGameMenu.h"
#include "StateGamePlay.h"
#include "StateMachine.h"
StateGameMenu::StateGameMenu(Context& context) : State(context)
{
//ctor
}
void StateGameMenu::sendConnexion(tgui::EditBox::Ptr username, tgui::EditBox::Ptr password)
{
m_context.Client->connexion(username->getText().toAnsiString(), password->getText().toAnsiString());
if(m_context.Client->estConnecte())
{
///The line below is the line triggering an error.
std::unique_ptr<State> temp = StateMachine::build<StateGamePlay>(m_context); ///The problem is here.
m_context.Machine->askPush(std::move(temp), true);
}
}
void StateGameMenu::loadGUI()
{
/* Some GUI Stuff ... */
button->connect("pressed", StateGameMenu::sendConnexion, this, editBoxUsername, editBoxPassword);
}
StateGameMenu::~StateGameMenu(){}
The error is :
conversion from 'std::unique_ptr<StateGamePlay, std::default_delete<StateGamePlay> >' to non-scalar type 'std::unique_ptr<State>' requested|
It's actually really diffcult for me to understand why the output of the function "build" isn't simply a "std::unique_ptr".
StateGamePlay.h
#ifndef STATEGAMEPLAY_H
#define STATEGAMEPLAY_H
#include "State.hpp"
class StateMachine;
class StateGamePlay : State
{
public:
StateGamePlay(Context& context);
virtual ~StateGamePlay();
protected:
private:
};
#endif // STATEGAMEPLAY_H
StateGamePlay.cpp
#include "StateGamePlay.h"
#include "StateMachine.h"
StateGamePlay::StateGamePlay(Context& context) : State(context)
{
//ctor
}
For more informations :
StateMachine.h
#ifndef STATEMACHINE_H
#define STATEMACHINE_H
#include <SFML/Graphics.hpp>
#include <stack>
#include <memory>
#include "Log.h"
#include "Context.h"
class State;
class StateMachine
{
public:
typedef std::unique_ptr<State> StatePtr;
StateMachine();
void askPush(StatePtr state, bool isReplacing = true);
void askPop();
template <typename T>
static std::unique_ptr<T> build( Context& context );
void processStateChanging();
virtual ~StateMachine();
protected:
void push();
void pop();
void resume();
void pause();
void modifyState();
std::stack<StatePtr> m_States;
bool m_isReplacing;
bool m_isChanging;
bool m_isDeleting;
StatePtr m_FutureChangingState;
private:
};
#include "State.hpp"
template <typename T>
std::unique_ptr<T> StateMachine::build( Context& context )
{
//return std::unique_ptr<T>( new T(context) );
return std::make_unique<T>( context );
}
#endif // STATEMACHINE_H
It seems like the problem is directly linked to the template function, but I don't see anything wrong with that part, and the call seems to be written correctly.
State.hpp
#ifndef STATE_H
#define STATE_H
#include <SFML/Graphics.hpp>
#include <TGUI/TGUI.hpp>
#include <memory>
#include "Client.h"
#include "Context.h"
class StateMachine;
class State
{
public:
State(Context& context);
State ( const State& ) = delete;
State& operator= ( const State& ) = delete;
void pause() {inPause = true;};
void resume() {inPause = false;};
virtual ~State();
protected:
bool inPause;
Context m_context;
private:
};
#endif // STATE_H
Context.h
#ifndef CONTEXT_H_INCLUDED
#define CONTEXT_H_INCLUDED
#include <SFML/Graphics.hpp>
#include <TGUI/TGUI.hpp>
#include <memory>
#include "Client.h"
class StateMachine;
struct Context
{
typedef std::shared_ptr<sf::RenderWindow> WindowPtr;
typedef std::shared_ptr<StateMachine> MachinePtr;
typedef std::shared_ptr<tgui::Gui> GuiPtr;
typedef std::shared_ptr<Client> ClientPtr;
Context(WindowPtr window, MachinePtr machine, GuiPtr gui, ClientPtr client);
WindowPtr Window;
MachinePtr Machine;
GuiPtr Gui;
ClientPtr Client;
};
Context::Context(WindowPtr window, MachinePtr machine, GuiPtr gui, ClientPtr client) :
Window(window), Machine(machine), Gui(gui), Client(client)
{ }
#endif // CONTEXT_H_INCLUDED
To finish, one of my main ressource to write that part is https://github.com/eXpl0it3r/SmallGameEngine/tree/master/ by eXpl0it3r (which is a change of an other code).
In this code, the way the State is given to the StateMachine is really similar to mine, however it doesn't work in my case and I don't know why.
And yes, I could clone my code on this one but I prefer to do that on my own.
I hope my post isn't too long and fuzzy as I am myself really confused. (And I didn't find anything to answer my question.)
Thank you for reading this whole post and for your time anyway ! (And sorry for my poor english).
c++ state c++17 unique-ptr
I am currently making an StateMachine for a game using several ressources on the web.
However, my issue came when I try to create a State to put it in the StateMachine.
The error is in the StateGameMenu.cpp, in sendConnexion.
StateGameMenu.h
#ifndef STATEGAMEMENU_H
#define STATEGAMEMENU_H
#include <TGUI/TGUI.hpp>
#include <SFML/Graphics.hpp>
#include <SFML/Network.hpp>
#include <memory>
#include <thread>
#include "Log.h"
#include "Client.h"
#include "Personnage.h"
#include "State.hpp"
class StateMachine;
class StateGameMenu : public State
{
public:
StateGameMenu(Context& context);
virtual ~StateGameMenu();
protected:
void sendConnexion(tgui::EditBox::Ptr username, tgui::EditBox::Ptr password);
void loadGUI();
private:
};
#endif // STATEGAMEMENU_H
StateGameMenu.cpp, where my error is.
#include "StateGameMenu.h"
#include "StateGamePlay.h"
#include "StateMachine.h"
StateGameMenu::StateGameMenu(Context& context) : State(context)
{
//ctor
}
void StateGameMenu::sendConnexion(tgui::EditBox::Ptr username, tgui::EditBox::Ptr password)
{
m_context.Client->connexion(username->getText().toAnsiString(), password->getText().toAnsiString());
if(m_context.Client->estConnecte())
{
///The line below is the line triggering an error.
std::unique_ptr<State> temp = StateMachine::build<StateGamePlay>(m_context); ///The problem is here.
m_context.Machine->askPush(std::move(temp), true);
}
}
void StateGameMenu::loadGUI()
{
/* Some GUI Stuff ... */
button->connect("pressed", StateGameMenu::sendConnexion, this, editBoxUsername, editBoxPassword);
}
StateGameMenu::~StateGameMenu(){}
The error is :
conversion from 'std::unique_ptr<StateGamePlay, std::default_delete<StateGamePlay> >' to non-scalar type 'std::unique_ptr<State>' requested|
It's actually really diffcult for me to understand why the output of the function "build" isn't simply a "std::unique_ptr".
StateGamePlay.h
#ifndef STATEGAMEPLAY_H
#define STATEGAMEPLAY_H
#include "State.hpp"
class StateMachine;
class StateGamePlay : State
{
public:
StateGamePlay(Context& context);
virtual ~StateGamePlay();
protected:
private:
};
#endif // STATEGAMEPLAY_H
StateGamePlay.cpp
#include "StateGamePlay.h"
#include "StateMachine.h"
StateGamePlay::StateGamePlay(Context& context) : State(context)
{
//ctor
}
For more informations :
StateMachine.h
#ifndef STATEMACHINE_H
#define STATEMACHINE_H
#include <SFML/Graphics.hpp>
#include <stack>
#include <memory>
#include "Log.h"
#include "Context.h"
class State;
class StateMachine
{
public:
typedef std::unique_ptr<State> StatePtr;
StateMachine();
void askPush(StatePtr state, bool isReplacing = true);
void askPop();
template <typename T>
static std::unique_ptr<T> build( Context& context );
void processStateChanging();
virtual ~StateMachine();
protected:
void push();
void pop();
void resume();
void pause();
void modifyState();
std::stack<StatePtr> m_States;
bool m_isReplacing;
bool m_isChanging;
bool m_isDeleting;
StatePtr m_FutureChangingState;
private:
};
#include "State.hpp"
template <typename T>
std::unique_ptr<T> StateMachine::build( Context& context )
{
//return std::unique_ptr<T>( new T(context) );
return std::make_unique<T>( context );
}
#endif // STATEMACHINE_H
It seems like the problem is directly linked to the template function, but I don't see anything wrong with that part, and the call seems to be written correctly.
State.hpp
#ifndef STATE_H
#define STATE_H
#include <SFML/Graphics.hpp>
#include <TGUI/TGUI.hpp>
#include <memory>
#include "Client.h"
#include "Context.h"
class StateMachine;
class State
{
public:
State(Context& context);
State ( const State& ) = delete;
State& operator= ( const State& ) = delete;
void pause() {inPause = true;};
void resume() {inPause = false;};
virtual ~State();
protected:
bool inPause;
Context m_context;
private:
};
#endif // STATE_H
Context.h
#ifndef CONTEXT_H_INCLUDED
#define CONTEXT_H_INCLUDED
#include <SFML/Graphics.hpp>
#include <TGUI/TGUI.hpp>
#include <memory>
#include "Client.h"
class StateMachine;
struct Context
{
typedef std::shared_ptr<sf::RenderWindow> WindowPtr;
typedef std::shared_ptr<StateMachine> MachinePtr;
typedef std::shared_ptr<tgui::Gui> GuiPtr;
typedef std::shared_ptr<Client> ClientPtr;
Context(WindowPtr window, MachinePtr machine, GuiPtr gui, ClientPtr client);
WindowPtr Window;
MachinePtr Machine;
GuiPtr Gui;
ClientPtr Client;
};
Context::Context(WindowPtr window, MachinePtr machine, GuiPtr gui, ClientPtr client) :
Window(window), Machine(machine), Gui(gui), Client(client)
{ }
#endif // CONTEXT_H_INCLUDED
To finish, one of my main ressource to write that part is https://github.com/eXpl0it3r/SmallGameEngine/tree/master/ by eXpl0it3r (which is a change of an other code).
In this code, the way the State is given to the StateMachine is really similar to mine, however it doesn't work in my case and I don't know why.
And yes, I could clone my code on this one but I prefer to do that on my own.
I hope my post isn't too long and fuzzy as I am myself really confused. (And I didn't find anything to answer my question.)
Thank you for reading this whole post and for your time anyway ! (And sorry for my poor english).
c++ state c++17 unique-ptr
c++ state c++17 unique-ptr
edited Jan 3 at 6:26
TagXy
asked Jan 3 at 5:41
TagXyTagXy
12
12
closed as off-topic by n.m., user4581301, S.M., P.W, llllllllll Jan 3 at 6:48
This question appears to be off-topic. The users who voted to close gave this specific reason:
- "Questions seeking debugging help ("why isn't this code working?") must include the desired behavior, a specific problem or error and the shortest code necessary to reproduce it in the question itself. Questions without a clear problem statement are not useful to other readers. See: How to create a Minimal, Complete, and Verifiable example." – n.m., user4581301, S.M., P.W, llllllllll
If this question can be reworded to fit the rules in the help center, please edit the question.
closed as off-topic by n.m., user4581301, S.M., P.W, llllllllll Jan 3 at 6:48
This question appears to be off-topic. The users who voted to close gave this specific reason:
- "Questions seeking debugging help ("why isn't this code working?") must include the desired behavior, a specific problem or error and the shortest code necessary to reproduce it in the question itself. Questions without a clear problem statement are not useful to other readers. See: How to create a Minimal, Complete, and Verifiable example." – n.m., user4581301, S.M., P.W, llllllllll
If this question can be reworded to fit the rules in the help center, please edit the question.
The error message refersStateGamePlay
. What isStateGamePlay
? IMHO too much code in the question and the important part is missing. Learn how to ask questions: Minimal, Complete, and Verifiable example
– S.M.
Jan 3 at 5:54
2
At the point where you request the conversion, the derived class is probably forward-declared and nothing is known about its base classes. We can't tell for sure becase you've chosen to omit the content of StateGamePlay.h. the only other relevant file beside that with the error.
– n.m.
Jan 3 at 6:00
Thank you for your answers. For me, I through it was obvious but it's stupid since I can miss an error. I edit my post to add the StateGamePlay.h and .cpp and I took off some useless information. And I try to find an issue with the order of the declarations but I miss it.
– TagXy
Jan 3 at 6:35
add a comment |
The error message refersStateGamePlay
. What isStateGamePlay
? IMHO too much code in the question and the important part is missing. Learn how to ask questions: Minimal, Complete, and Verifiable example
– S.M.
Jan 3 at 5:54
2
At the point where you request the conversion, the derived class is probably forward-declared and nothing is known about its base classes. We can't tell for sure becase you've chosen to omit the content of StateGamePlay.h. the only other relevant file beside that with the error.
– n.m.
Jan 3 at 6:00
Thank you for your answers. For me, I through it was obvious but it's stupid since I can miss an error. I edit my post to add the StateGamePlay.h and .cpp and I took off some useless information. And I try to find an issue with the order of the declarations but I miss it.
– TagXy
Jan 3 at 6:35
The error message refers
StateGamePlay
. What is StateGamePlay
? IMHO too much code in the question and the important part is missing. Learn how to ask questions: Minimal, Complete, and Verifiable example– S.M.
Jan 3 at 5:54
The error message refers
StateGamePlay
. What is StateGamePlay
? IMHO too much code in the question and the important part is missing. Learn how to ask questions: Minimal, Complete, and Verifiable example– S.M.
Jan 3 at 5:54
2
2
At the point where you request the conversion, the derived class is probably forward-declared and nothing is known about its base classes. We can't tell for sure becase you've chosen to omit the content of StateGamePlay.h. the only other relevant file beside that with the error.
– n.m.
Jan 3 at 6:00
At the point where you request the conversion, the derived class is probably forward-declared and nothing is known about its base classes. We can't tell for sure becase you've chosen to omit the content of StateGamePlay.h. the only other relevant file beside that with the error.
– n.m.
Jan 3 at 6:00
Thank you for your answers. For me, I through it was obvious but it's stupid since I can miss an error. I edit my post to add the StateGamePlay.h and .cpp and I took off some useless information. And I try to find an issue with the order of the declarations but I miss it.
– TagXy
Jan 3 at 6:35
Thank you for your answers. For me, I through it was obvious but it's stupid since I can miss an error. I edit my post to add the StateGamePlay.h and .cpp and I took off some useless information. And I try to find an issue with the order of the declarations but I miss it.
– TagXy
Jan 3 at 6:35
add a comment |
1 Answer
1
active
oldest
votes
Instance of StateGamePlay
cannot be created because State
constructor is private.
class StateGamePlay : State // default private inheritance
should be
class StateGamePlay : public State
Thank you very much, it works, the problem was simple in the end. I have other issues now but I will handle them on my own.
– TagXy
Jan 3 at 6:39
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
Instance of StateGamePlay
cannot be created because State
constructor is private.
class StateGamePlay : State // default private inheritance
should be
class StateGamePlay : public State
Thank you very much, it works, the problem was simple in the end. I have other issues now but I will handle them on my own.
– TagXy
Jan 3 at 6:39
add a comment |
Instance of StateGamePlay
cannot be created because State
constructor is private.
class StateGamePlay : State // default private inheritance
should be
class StateGamePlay : public State
Thank you very much, it works, the problem was simple in the end. I have other issues now but I will handle them on my own.
– TagXy
Jan 3 at 6:39
add a comment |
Instance of StateGamePlay
cannot be created because State
constructor is private.
class StateGamePlay : State // default private inheritance
should be
class StateGamePlay : public State
Instance of StateGamePlay
cannot be created because State
constructor is private.
class StateGamePlay : State // default private inheritance
should be
class StateGamePlay : public State
answered Jan 3 at 6:33
rafix07rafix07
8,2931816
8,2931816
Thank you very much, it works, the problem was simple in the end. I have other issues now but I will handle them on my own.
– TagXy
Jan 3 at 6:39
add a comment |
Thank you very much, it works, the problem was simple in the end. I have other issues now but I will handle them on my own.
– TagXy
Jan 3 at 6:39
Thank you very much, it works, the problem was simple in the end. I have other issues now but I will handle them on my own.
– TagXy
Jan 3 at 6:39
Thank you very much, it works, the problem was simple in the end. I have other issues now but I will handle them on my own.
– TagXy
Jan 3 at 6:39
add a comment |
The error message refers
StateGamePlay
. What isStateGamePlay
? IMHO too much code in the question and the important part is missing. Learn how to ask questions: Minimal, Complete, and Verifiable example– S.M.
Jan 3 at 5:54
2
At the point where you request the conversion, the derived class is probably forward-declared and nothing is known about its base classes. We can't tell for sure becase you've chosen to omit the content of StateGamePlay.h. the only other relevant file beside that with the error.
– n.m.
Jan 3 at 6:00
Thank you for your answers. For me, I through it was obvious but it's stupid since I can miss an error. I edit my post to add the StateGamePlay.h and .cpp and I took off some useless information. And I try to find an issue with the order of the declarations but I miss it.
– TagXy
Jan 3 at 6:35