#Unique_ptr and Game State changes

6 messages · Page 1 of 1 (latest)

true zenithBOT
#

When your question is answered use !solved to mark the question as resolved.

Remember to ask specific questions, provide necessary details, and reduce your question to its simplest form. For tips on how to ask a good question use !howto ask.

jolly elm
#
CStateManager::CStateManager(sf::RenderWindow& Window) :
    mState(nullptr),
    mGameplay(std::make_unique<CGameplay>(Window)), 
    mTitle_Screen(std::make_unique<CTitle_Screen>(Window))
{}

auto CStateManager::set_state(std::unique_ptr<CState> State) -> void
{
    mState = std::move(State);
}

auto CStateManager::get_gameplay() -> std::unique_ptr<CGameplay>
{
    return std::make_unique<CGameplay>();
}

auto CStateManager::get_title_screen() -> std::unique_ptr<CTitle_Screen>
{
    return std::make_unique<CTitle_Screen>();
}
#
class CStateManager
{
private:
    std::unique_ptr<CState> mState;
    std::unique_ptr<CGameplay> mGameplay;
    std::unique_ptr<CTitle_Screen> mTitle_Screen;
#

and when i try to StateManager.set_state(StateManager.get_title_screen()); vs22 passes me a C++ no suitable user-defined conversion from to existserror

true zenithBOT
#

@jolly elm

Please Do Not Delete Posts!

Please don't delete forum posts. They can be helpful to refer to later and other members can learn from them. In the future you can use !solved to close a post and mark a post as solved.

jolly elm
#

!solved