Can't create object of derived class wxFrame Topic is solved

If you are using the main C++ distribution of wxWidgets, Feel free to ask any question related to wxWidgets development here. This means questions regarding to C++ and wxWidgets, not compile problems.
Post Reply
jaxsin
Earned a small fee
Earned a small fee
Posts: 18
Joined: Fri Feb 27, 2015 10:37 pm

Can't create object of derived class wxFrame

Post by jaxsin »

I'm not sure what my problem is exactly, what I want to do is make a private member variable accessible outside the class

BaseWindow.h

Code: Select all

#include "Dialogs.h"

class BaseWindow : public wxFrame
{

friend class PortSettings;

public:
	// Constructor
	BaseWindow(const wxString & title);
	~BaseWindow();
		
private:
	...
	
	// Class members
	wxFileConfig *pConfig;
	...
};
Dialog.h

Code: Select all

class PortSettings : public wxDialog
{

public:
	// Constructor & Destructor
	PortSettings();
	void Create();
		

private:
	// Member
	BaseWindow *bw;
	
};
This is what I want to do

Code: Select all

bw->pConfig->Read()
The problem is it doesn't work. I get an error on this line BaseWindow *bw, and I do not understand what it means or how to fix it. Obviously I am doing it wrong. Been staring at this problem for a day and still confused.
Error 1 error C2143: syntax error : missing ';' before '*' (ChartDlg.cpp) c:\users\jasin\documents\visual studio 2013\projects\yapper-app\yapper-app\Dialogs.h 27 1 Yapper
Error 2 error C4430: missing type specifier - int assumed. Note: C++ does not support default-int (ChartDlg.cpp) c:\users\jasin\documents\visual studio 2013\projects\yapper-app\yapper-app\Dialogs.h 27 1 Yapper
Error 3 error C2143: syntax error : missing ';' before '*' (AppMain.cpp) c:\users\jasin\documents\visual studio 2013\projects\yapper-app\yapper-app\Dialogs.h 27 1 Yapper
Error 4 error C4430: missing type specifier - int assumed. Note: C++ does not support default-int (AppMain.cpp) c:\users\jasin\documents\visual studio 2013\projects\yapper-app\yapper-app\Dialogs.h 27 1 Yapper
Error 5 error C2143: syntax error : missing ';' before '*' (BaseWindow.cpp) c:\users\jasin\documents\visual studio 2013\projects\yapper-app\yapper-app\Dialogs.h 27 1 Yapper
Error 6 error C4430: missing type specifier - int assumed. Note: C++ does not support default-int (BaseWindow.cpp) c:\users\jasin\documents\visual studio 2013\projects\yapper-app\yapper-app\Dialogs.h 27 1 Yapper
Error 7 error C2143: syntax error : missing ';' before '*' (PortSettingsDlg.cpp) c:\users\jasin\documents\visual studio 2013\projects\yapper-app\yapper-app\Dialogs.h 27 1 Yapper
Error 8 error C4430: missing type specifier - int assumed. Note: C++ does not support default-int (PortSettingsDlg.cpp) c:\users\jasin\documents\visual studio 2013\projects\yapper-app\yapper-app\Dialogs.h 27 1 Yapper
catalin
Moderator
Moderator
Posts: 1618
Joined: Wed Nov 12, 2008 7:23 am
Location: Romania

Re: Can't create object of derived class wxFrame

Post by catalin »

Do you have the needed includes [in the correct order] in the cpp files? You might consider adding forward declarations in the headers, to not depend on the order of the includes.
jaxsin
Earned a small fee
Earned a small fee
Posts: 18
Joined: Fri Feb 27, 2015 10:37 pm

Re: Can't create object of derived class wxFrame

Post by jaxsin »

Yep, that was the problem. I just forward declared BaseWindow in dialog.h and all is well with the necessary includes.

Guess I was just missing out on the combination I needed of includes and forward declarations.
Post Reply