[英]Expected Expression in C++, but I can't find the error
我最近買了一本書,名為“ SFML游戲開發示例”,該代碼給了我一些問題。
這是給我帶來麻煩的行:
m_window.create({ m_windowSize.x, m_windowSize.y, 32 }, m_windowTitle, style);
括號與花括號相遇的地方({
它告訴我,有一個預期的表達。
這是整個文件的代碼
#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);
}
我做了我能想到的一切。 我什至從書的網站上下載了源代碼,我檢查了書的勘誤表,看是否應該進行更改。 在這本書上的其他人似乎沒有問題,而下載源代碼仍然給我一個錯誤,這一事實使我認為這與我有關,但是又是什么呢?
您的代碼需要支持編譯器不支持的C ++ 11功能。 請參閱VS2012的C ++ 11功能列表。 如果要編譯C ++ 11代碼,請升級到完全支持C ++ 11的最新版本。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.