建设者
PixelPlane::PixelPlane(int& width, int& height, const std::string& label)
Run Code Online (Sandbox Code Playgroud)
每当我使用以下参数初始化对象时
PixelPlane pixel_plane(960, 540, "Title");
Run Code Online (Sandbox Code Playgroud)
Visual Studio在960参数下划线并显示消息No instance of constructor "PixelPlane::PixelPlane matches the argument list. Argument types are: (int, int, const char[5])。我看到有人做了类似的事情而没有错误https://www.youtube.com/watch?v=1nfuYMXjZsA。我做错了什么还是只是忽略了什么?
当我将 aconst char*作为函数参数传递时(像这样):
void print(const char* text)
{
std::cout << text << std::endl;
}
Run Code Online (Sandbox Code Playgroud)
会自动删除吗?如果没有,它会发生什么,我应该如何删除它?
我正在创建一个GLFWKeyCallback,由于它非常简单,我决定使用 lambda。这个回调修改了一个成员变量,所以我必须将其传递到捕获列表中。到目前为止,我的代码如下所示:
glfwSetKeyCallback(window,
[this](GLFWwindow* window, int key, int scancode, int action, int mods)
{
if(action == GLFW_PRESS)
{
//use a mutex
//Modify member variable
}
});
Run Code Online (Sandbox Code Playgroud)
问题是,每当我将其传递到捕获列表时,Visual Studio 2019 都会显示以下错误:
不存在从“lambda [] void (GLFWwindow *window, int key, int scancode, int action, int mods)->void”到 GLFWKeyfun”的合适转换函数
我是否错过了什么或者该代码只是无效?