当我运行程序时,我完全不确定为什么我在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 ++开发基于文本的游戏。我想知道如何在不嵌套太多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语句的情况下执行此概念?