将成员函数作为构造函数参数调用时出错 "Variable is not a type name"
Error calling member function as constructor parameter "Variable is not a type name"
我想将本地实例的成员函数的输出作为构造函数的参数传递。我正在使用 SFML 库。
鲍尔·
Ball(sf::Vector2f _dvelocity, sf::Vector2f _position, sf::Vector2f _origin, sf::Texture _texture, float _dvmagnitude )
{
dvelocity = _dvelocity;
position = _position;
sprite.setTexture(_texture);
sprite.setOrigin(_origin);
dvmagnitude = _dvmagnitude;
}
主.cpp
sf::RenderWindow window(sf::VideoMode(640, 480), "Pong");
sf::Event event;
sf::Texture pongTexture;
pongTexture.loadFromFile("frost mage.PNG");
Ball ball(sf::Vector2f _dvelocity(), sf::Vector2f _position(), window.getSize(), pongTexture, 1);
该错误由main.cpp最后一行中的"window.getSize(("触发。我的调试器显示"窗口不是类型名称"。
该错误是由构造函数定义引起的,您在其中获取sf::Vector2f _origin
参数,然后window.getSize()
返回sf::Vector2U
。尝试将参数更改为sf::Vector2U _origin
。
相关文章:
- C++ Singleton - Prevent ::instance() to variable
- Why is UINT32_MAX + 1 = 0?
- C++错误:"error: int aaa::bbb is protected within this context"
- 创建具有 new in 函数和"this is nullptr"异常的对象
- 使用 cmake 的 Linux 终端上的"Conversion to non-scalar type is requested"错误
- Is !NaN not a NaN?
- Directx 11 - CompileFromFile() is not compiling
- 如何通过多类"Union variable" (sfml) 使用轮询事件
- Centos7 g++ "to_string is not in a member of std"
- "Unable to start debugging. No process is associated with this object." - 在Visual Studio Code中使用GDB
- Where is std::hardware_destructive_interference_size?
- 将成员函数作为构造函数参数调用时出错 "Variable is not a type name"
- 为什么我会收到"Run-Time Check Failure #2 - Stack around the variable 'pr' was corrupted"错误?
- 如何在Visual Studio 2019中修复"[member variable that is a vulkan struct] is uninitialized. Always initiali
- C++ 模板:'Instantiation of variable required here, but no definition is available'
- 分配给数组成员时在 Clang 中"Read-only variable is not assignable"
- " a variable that can be easily mistaken for a constant variable but is in fact a non-constant varia
- 这"if e is a pack, then get a template name, otherwise get a variable name"有效与否?
- 收到警告 C4189 "local variable is initialized but not referenced"即使正在引用变量
- decltype - "the only context in which a variable defined as a reference is not treated as a synonym