简体   繁体   English

C ++中的预期表达式,但找不到错误

[英]Expected Expression in C++, but I can't find the error

I recently bought a book called "SFML Game Development by Example" and the code is giving me some problems. 我最近买了一本书,名为“ SFML游戏开发示例”,该代码给了我一些问题。

Here is the line giving me trouble: 这是给我带来麻烦的行:

m_window.create({ m_windowSize.x, m_windowSize.y, 32 }, m_windowTitle, style);

Where the bracket meets the curly brace ({ it tells me that there is an expected expression. 括号与花括号相遇的地方({它告诉我,有一个预期的表达。

Here is the code for the entire file 这是整个文件的代码

#include "Window.h"

Window::Window(){
    Setup("Window", sf::Vector2u(640, 480));
}

Window::Window(const std::string& l_title, const sf::Vector2u& l_size){
    Setup(l_title, l_size);
}

Window::~Window(){
    Destroy();
}

void Window::Setup(const std::string& l_title, const sf::Vector2u& l_size){
    m_windowTitle = l_title;
    m_windowSize = l_size;
    m_isFullscreen = false;
    m_isDone = false;
    Create();
}

void Window::Create(){
    auto style = (m_isFullscreen ? sf::Style::Fullscreen : sf::Style::Default);
    m_window.create({ m_windowSize.x, m_windowSize.y, 32 }, m_windowTitle, style);
}

void Window::Destroy(){
    m_window.close();
}

void Window::Update(){
    sf::Event event;
    while(m_window.pollEvent(event)){
        if(event.type == sf::Event::Closed){
            m_isDone = true;
        }else if(event.type == sf::Event::KeyPressed && event.key.code == sf::Keyboard::F5){
            ToggleFullscreen();
        }
    }
}

void Window::ToggleFullscreen(){
    m_isFullscreen = !m_isFullscreen;
    Destroy();
    Create();
}

void Window::BeginDraw(){
    m_window.clear(sf::Color::Black);
}

void Window::EndDraw(){
    m_window.display();
}

bool Window::IsDone(){
    return m_isDone;
}

bool Window::IsFullscreen(){
    return m_isFullscreen;
}

sf::Vector2u Window::GetWindowSize(){
    return m_windowSize;
}

void Window::Draw(sf::Drawable& l_drawable){
    m_window.draw(l_drawable);
}

I've done everything I can think of. 我做了我能想到的一切。 I've even downloaded the source code from the book's website, Ive checked the books errata to see if there should have been a change. 我什至从书的网站上下载了源代码,我检查了书的勘误表,看是否应该进行更改。 Other people working on this book seem to have no problem at this part and the fact that downloading the source code still gives me the error makes me think it has something to do with me, but what? 在这本书上的其他人似乎没有问题,而下载源代码仍然给我一个错误,这一事实使我认为这与我有关,但是又是什么呢?

Your code requires support for C++ 11 features that your compiler doesn't support. 您的代码需要支持编译器不支持的C ++ 11功能。 See the C++11 features list for VS2012. 请参阅VS2012的C ++ 11功能列表。 Upgrade to a more recent version that fully supports C++11 if you want to compile C++11 code. 如果要编译C ++ 11代码,请升级到完全支持C ++ 11的最新版本。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM