I'm not quite sure if this should be consider as a C++ question or a wxWidgets:
I'm working on a fairly simple wxWidgets interface that will allow the user to draw triangles. Thus, I have a canvas (OpenGLCanvas class) and a wxWindow (CMainFrame class) the problem is that I want my canvas to have an instance of my window and vice versa. The source of the error is that for the time the compiler has reached the part of the OpenGLCanvas where my CMainFrame instance is, it(the CMainFrame) has not been defined and the same thing happens if I change the order of the #includes here is my code:
OpenGLCanvas.cpp:
#include "mainframe.h"
#include "openglcanvas.h"
...
OpenGLCanvas::OpenGLCanvas(wxWindow *parent, wxWindowID id,const wxPoint& pos, const wxSize& size,long style, const wxString& name):
wxGLCanvas(parent, id, pos, size, style, name)
{
frame = (CMainFrame) parent;
}
openGLCanvas.h:
#ifndef __OPENGLCANVAS_H__
#define __OPENGLCANVAS_H__
#include "wx/wx.h"
#include <wx/glcanvas.h>
class OpenGLCanvas: public wxGLCanvas {
public:
CMainFrame* frame;
...
#endif
mainframe.cpp:
#include "openglcanvas.h"
#include "mainframe.h"
...
CMainFrame::CMainFrame(wxMenuBar* menu, const wxString& title, const wxPoint& pos, const wxSize& size)
: wxFrame((wxFrame *)NULL, -1, title, pos, size)
{
m_menu=menu;
canvas = new OpenGLCanvas((wxWindow*)this,-1, pos , size, 0 , wxT("Canvas"));
}//constructor
...
mainframe.h
#ifndef __MAINFRAME_H__
#define __MAINFRAME_H__
...
class CMainFrame: public wxFrame {
public:
CMainFrame(wxMenuBar* menu,const wxString& title, const wxPoint& pos, const wxSize& size);
How am I supposed to include this files? (I am fairly new to C++ but not to C) I apologize for the length of my question. Any ideas would be of great help.
Thank you.