I am trying to utilize wxWidgets in Visual Studio (2017) C++. I created two classes. Namely, cApp.h and cMain.h. Then i tried to create new instance of Cmain in cApp. However, it below error:
Error C2248 'cMain::cMain': cannot access private member declared in class 'cMain'
When I hover over the .h file in Solution Explorer in Visual Studio it shows it is private. I deleted them and created them manually. However, the same result. How can I change it to public? Thank you very much :)
cApp.h
#pragma once
#include "wx/wx.h"
#include "cMain.h"
class cApp : public wxApp
{
public:
cApp();
~cApp();
private:
cMain* m_frame1 = nullptr;
public:
virtual bool OnInit();
};
cApp.cpp
#include "cApp.h"
wxIMPLEMENT_APP(cApp);
bool cApp::OnInit()
{
m_frame1 = new cMain(); // This is the part that gives error
m_frame1->Show();
return true;
}
cMain.h
#include "wx/wx.h"
class cMain : public wxFrame
{
cMain();
~cMain();
};
cMain.cpp
#include "cMain.h"
cMain::cMain() : wxFrame(nullptr, wxID_ANY, "First App")
{
}
cMain::~cMain()
{
}