So here is the error: 1>c:\users\ben\documents\visual studio 2010\projects\opengl_learning\opengl_learning_without_glut\openglcontext.cpp(18): error C2533: 'OpenGLContext::{ctor}' : constructors not allowed a return type
And here is a block of code where the error points, specifically the error originates from the default constructor:
#include <Windows.h>
#include <iostream>
#include "OpenGLContext.h"
/**
Default constructor for the OpenGLContext class. At this stage it does nothing
but you can put anything you want here.
*/
OpenGLContext::OpenGLContext(void){}
OpenGLContext::OpenGLContext(HWND hwnd) {
createContext(hwnd);
}
/**
Destructor for our OpenGLContext class which will clean up our rendering context
and release the device context from the current window.
*/
OpenGLContext::~OpenGLContext(void) {
wglMakeCurrent(hdc, 0); // Remove the rendering context from our device context
wglDeleteContext(hrc); // Delete our rendering context
ReleaseDC(hwnd, hdc); // Release the device context from our window
}
Why!?
Most likely you forgot a semicolon after OpenGLContext
's definition. Then your code is parsed as
class OpenGLContext { /* ... */ } OpenGLContext::OpenGLContext(void) { }
That's valid syntactically. But as constructors don't have a return type, like the message says, the compiler complains.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With