Reputation: 301
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!?
Upvotes: 11
Views: 13064
Reputation: 361812
Open the file OpenGLContext.h
and make sure if you've put semicolon after OpenGLContext
class definition.
Upvotes: 2
Reputation: 507433
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.
Upvotes: 32