Quantcast
Channel: C++ Using an enum from another class properly - Stack Overflow
Viewing all articles
Browse latest Browse all 3

C++ Using an enum from another class properly

$
0
0

I'm currently implementing some code using OpenGL and I've created wrappers for various OpenGL classes. In particular, I have a buffer class that can represent either a vertex array buffer or an element array buffer. To do this, I declared my class in the header like so:

Buffer.hnamespace FE { namespace GL {    enum BufferType {        ARRAY = GL_ARRAY_BUFFER,        ELEMENT = GL_ELEMENT_ARRAY_BUFFER    };    class Buffer {    public:        Buffer(BufferType type);        ... rest of class ...    };}

In my Renderer class, I try to instantiate some buffers as class members:

Renderer.h...#include "../GL/Buffer.h"namespace FE { namespace Render {    class Renderer {    ...    private:        GL::Buffer vbo(GL::BufferType::ARRAY);        GL::Buffer element(GL::BufferType::ELEMENT);    };    }}

For some reason, attempting to use the enum this way gives me the errors "syntax error: identifier 'ELEMENT'". Intellisense also warns that "constant 'FE::GL::ELEMENT' is not a type name."

I'm not quite sure why this doesn't work, as before while testing my buffer related code I created buffers in a similar manner (by accessing the enum values with the scope operator).

Any help on how to fix this issue would be appreciated.


Viewing all articles
Browse latest Browse all 3

Latest Images

Trending Articles





Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>
<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596344.js" async> </script>