c3867'sf::时间::作为秒':非标准语法;使用"&"创建指向成员的指针

c3867'sf::Time::as seconds':non-standard syntax ;use '&'to create a pointer to a member

本文关键字:创建 指针 使用 成员 时间 sf 非标准 c3867 语法      更新时间:2023-10-16
#include<SFML/Graphics.hpp>
#include<iostream>

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>------ 构建已开始:项目:SFML-2.0,配置:调试 Win32 ------ 1> 主要.cpp 1>c:\users\paribeshpc\documents\Visual Studio 2015\projects\sfml-2.0\sfml-2.0\main.cpp(11):错误 C3867:"sf::Time::asSeconds":非标准语法;使用"&"创建指向成员的指针 =====

===== 构建:0 成功,1 失败,0 最新,0 跳过 ==========

请帮助我,我一直收到此错误。我正在从这个dued学习sfml,我从他那里复制了这段代码,但它不起作用。 视频链接

sf::Time::asSeconds是一个

函数,你需要调用它:

std::cout << time.asSeconds() << std::endl;
//                         ^^
//      Note parentheses here

现在发生的情况是编译器认为您想要指向该函数的指针,这就是为什么它告诉您使用地址运算符&