【问题标题】:c3867'sf::Time::as seconds':non-standard syntax ;use '&'to create a pointer to a memberc3867'sf::Time::as seconds':非标准语法;使用'&'创建指向成员的指针
【发布时间】:2016-07-10 18:44:51
【问题描述】:
#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 跳过 ==========

请帮助我,我不断收到此错误。我正在从这个到期中学习 sfml,我从他那里复制了这段代码,但它不起作用。 The link to the video

【问题讨论】:

  • time.asSeconds() ?

标签: c++ sfml


【解决方案1】:

sf::Time::asSeconds是一个函数,你需要调用它:

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

现在发生的事情是编译器认为你想要一个指向函数的指针,这就是为什么它告诉你使用地址运算符&amp;

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2020-03-30
    • 1970-01-01
    • 2021-03-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多