[英]c3867'sf::Time::as seconds':non-standard syntax ;use '&'to create a pointer to a member
#include<SFML/Graphics.hpp>
#include<iostream>
int main() { int main() {
sf::RenderWindow Window;
Window.create(sf::VideoMode(800, 600), "Game Engine");
sf::Time time = sf::seconds(2);
std::cout << time.asSeconds << std::endl;
while (Window.isOpen()) {
sf::Event Event;
while (Window.pollEvent(Event)) {
if (Event.type == sf::Event::Closed) {
Window.close();
}
Window.display();
}
{
}
}
} }
1>------ Build started: Project: SFML-2.0, Configuration: Debug Win32 ------ 1> Main.cpp 1>c:\\users\\paribeshpc\\documents\\visual studio 2015\\projects\\sfml-2.0\\sfml-2.0\\main.cpp(11): error C3867: 'sf::Time::asSeconds': non-standard syntax;
1>------ 构建开始:项目:SFML-2.0,配置:Debug Win32 ------ 1> Main.cpp 1>c:\\users\\paribeshpc\\documents\\visual studio 2015\\projects\\sfml -2.0\\sfml-2.0\\main.cpp(11): 错误 C3867: 'sf::Time::asSeconds': 非标准语法; use '&' to create a pointer to member ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
使用“&”创建指向成员的指针 ========== 构建:0 成功,1 失败,0 最新,0 跳过 ==========
Please help me, I keep getting this error.请帮助我,我不断收到此错误。 I was learning sfml from this dued and I copied this code from him but its not working.
我正在从这个到期中学习 sfml,我从他那里复制了这段代码,但它不起作用。 The link to the video
视频链接
sf::Time::asSeconds
is a function , you need to call it: sf::Time::asSeconds
是一个函数,你需要调用它:
std::cout << time.asSeconds() << std::endl;
// ^^
// Note parentheses here
What happens right now is that the compiler thinks you want a pointer to the function, which is why it tells you to use the address-of operator &
.现在发生的事情是编译器认为你想要一个指向函数的指针,这就是为什么它告诉你使用地址运算符
&
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.