c3867'sf::时间::作为秒':非标准语法;使用"&"创建指向成员的指针
c3867'sf::Time::as seconds':non-standard syntax ;use '&'to create a pointer to a member
#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
现在发生的情况是编译器认为您想要指向该函数的指针,这就是为什么它告诉您使用地址运算符&
。
相关文章:
- 如何创建指针链?我想创建具有指向更多对象的指针的对象,该对象具有指针.这可能吗?
- c++ 获取非语法使用"&"创建指针
- 在自定义构造函数中的堆上创建指针
- 创建指针是否超过非数组指针的末尾,而不是从 C++17 中的一元运算符和未定义的行为派生?
- 创建指针会占用大量资源吗?
- 创建指针时是否没有构造函数调用
- 以不寻常的方式创建指针
- 在类中创建指针到另一个对象
- Visual Studio 2015"非标准语法;使用"&"为成员创建指针"
- 创建指针 C++ 时获取段错误
- 当我在 c++ 中创建指针数组时无法读取的内存
- 创建指针列表的正确范例是什么
- 如何在C 11中创建指针映射以静态成员功能
- 奇怪的错误:当没有真正创建指针时,使用已删除的函数'std::unique_ptr<_Tp,_Dp>::unique_ptr
- 如何使用双指针创建指针数组?
- 创建指针数组
- C++:创建指针的副本
- 使用new创建指针数组,这样指针就不会初始化为NULL
- 如何在不从参数列表中创建对象的情况下创建指针
- 如何在定义后创建指针和结构实例