小编Dan*_*ier的帖子

为什么调用带有未声明变量的仿函数有效?

class foo {
    public:
    bool operator () (int & i) {
        return true;
    }
};

int main() {
    foo(WhyDoesThisCompile);
    return 0;
}
Run Code Online (Sandbox Code Playgroud)

当传递WhyDoesThisCompile(没有空格)到仿函数时,程序编译.

为什么是这样?我在clang 4.0.0上测试过它.

c++ compilation functor most-vexing-parse

21
推荐指数
1
解决办法
1243
查看次数

为什么C++ OBJ文件很重要?

请注意,我是C++的新手.

当我编译我的程序时,我注意到我为每个类创建了一个.obj.当我查看程序文件中的其他程序时,我意识到这些程序几乎没有任何.obj,所以我猜我做错了.

此外,如果我从发布目录中删除obj文件并尝试再次运行exe并且它仍然像以前一样工作,我知道这些文件不能毫无意义但是......

它们的用途是什么?它应该为每个类文件制作它们吗? - 如果不是我如何解决这个问题?

当我编译时,如何将它们放在一个名为obj的文件夹中的目录中?

c++

16
推荐指数
3
解决办法
1万
查看次数

0xC0000005:访问冲突执行位置0x00000000.(OpenGL的)

我已经在堆栈上看了几个关于这个问题的其他问题,它提到了取消引用空指针,但我不明白这是否适用于我的代码.

在尝试生成VAO时,代码在World.cpp的第33行崩溃:

glGenVertexArrays(1, &vao);
Run Code Online (Sandbox Code Playgroud)

给我标题中显示的错误.如果我注释掉该行程序运行正常.

PhaseEngineMain.cpp

#include "PhaseEngineMain.h"
#include "PhaseEngineController.h"

int main(int argc, char *argv[])
{
    PhaseEngineController engine;
    engine.start();
    return 0;
}
Run Code Online (Sandbox Code Playgroud)

PhaseEngineController.h

#pragma once
#include "SDL.h"
#include "glew.h"
#include "World.h"
#include <iostream>

class PhaseEngineController
{
public:
    PhaseEngineController();
    ~PhaseEngineController();

    void InitialiseEngine();
    void IntitialseOpenGL();
    void InitialiseSDL(Uint32 x, Uint32 y, Uint32 width, Uint32 height, Uint32 flags);
    void InitialiseGLEW();
    void SetClearColour(float r, float g, float b, float a);
    void PrintIntialisationInfo();
    void start();
    void stop();
    void run();
    void UpdateLoop();
    void RenderLoop();
    void SwapBackBuffer();

private: …
Run Code Online (Sandbox Code Playgroud)

c++ opengl glew access-violation

2
推荐指数
1
解决办法
8442
查看次数