小编fre*_*098的帖子

ArticxEngine.exe中0x777122D2(ntdll.dll)的未处理异常:0xC0000005:访问冲突写入位置0x00000004

当我运行程序时,我完全不确定为什么我在VS2012中收到此错误.Visual Studio似乎将问题引向sf::RenderWindow Articx::window;Articx.cpp

ArticxEngine.exe中0x777122D2(ntdll.dll)的未处理异常:0xC0000005:访问冲突写入位置0x00000004.

Articx.h

#pragma once

#include <SFML/Graphics.hpp>
#include <SFML/Window.hpp>

class Articx
{
    public:
        static void Start();
    private:
        static void GameLoop();

        static bool isExiting();

        enum ScreenState {before, splash1, splash2, splash3, menu, pause, playing, exit};
        static ScreenState currentState;

        static sf::RenderWindow window;
};
Run Code Online (Sandbox Code Playgroud)

Articx.cpp

#include <SFML/Graphics.hpp>
#include <SFML/System.hpp>
#include <SFML/Window.hpp>
#include <iostream>
#include <string>
#include "Articx.h"

inline void Message(char message[]);
inline void CallError(int code, char message[]);

Articx::ScreenState Articx::currentState = Articx::before;
sf::RenderWindow Articx::window;

void Articx::Start()
{
    Message("Articx …
Run Code Online (Sandbox Code Playgroud)

c++ sfml

2
推荐指数
1
解决办法
1万
查看次数

基于文本的游戏非分支if语句

我正在使用C ++开发基于文本的游戏。我想知道如何在不嵌套太多if语句的情况下进入不同的事件。我在说的一个例子是...

if ( userChoice == 1 )
{
     //do something
     cout << "Pick 1 , 2, or 3" << endl;
     if ( userChoice == 1 )
     {
           cout << "pick 1, 2, 3/ some storry line" << endl;
           if ( userChoice == 3 )
           {
                cout << " storyline...123...." << endl;
                if ( userChoice == 2 )
                {
                       //etc
                }
           }
     }
}
Run Code Online (Sandbox Code Playgroud)

我如何在不分支if语句的情况下执行此概念?

c++ if-statement

1
推荐指数
1
解决办法
769
查看次数

标签 统计

c++ ×2

if-statement ×1

sfml ×1