Я борюсь с библиотекой JUCE, потому что я следую учебным пособиям по GUI, и по какой-то причине я не могу использовать синтаксис «нового экземпляра» внутри функции инициализации.Есть ли что-то конкретное в этом конкретном блоке, что не позволяет использовать оператор «new» для создания экземпляра класса окна GUI?
#include "../JuceLibraryCode/JuceHeader.h"
#include "MainComponent.h"
#include <iostream>
/* Auto generated code*/
class MyApplication: public JUCEApplication
{
public:
//==============================================================================
MyApplication() {}
const String getApplicationName() override { return ProjectInfo::projectName; }
const String getApplicationVersion() override { return ProjectInfo::versionString; }
bool moreThanOneInstanceAllowed() override { return true; }
//==============================================================================
void initialise (const String& commandLine) override
{
MyWindow.reset (new The_Main_Window (getApplicationName()));
MyWindow = new The_Main_Window(getApplicationName()); //New instance syntax.
}
void shutdown() override
{
// Add your application's shutdown code here..
MyWindow = nullptr; // (deletes our window)
}
//==============================================================================
void systemRequestedQuit() override
{
// This is called when the app is being asked to quit: you can ignore this
// request and let the app carry on running, or call quit() to allow the app to close.
quit();
}
void anotherInstanceStarted (const String& commandLine) override
{
// When another instance of the app is launched while this one is running,
// this method is invoked, and the commandLine parameter tells you what
// the other instance's command-line arguments were.
}
//==============================================================================
/*
This class implements the desktop window that contains an instance of
our MainComponent class.
*/
class The_Main_Window : public DialogWindow
{
public:
The_Main_Window (String name) : DialogWindow (name, Colours::beige,DialogWindow::allButtons)
{
setUsingNativeTitleBar (true);
setContentOwned (new MainComponent(), true);
setResizable (true, true);
centreWithSize (300, 600);
setVisible (true);
}
void closeButtonPressed() override
{
JUCEApplication::getInstance()->systemRequestedQuit();
}
private:
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (The_Main_Window)
};
private:
std::unique_ptr<The_Main_Window> MyWindow; // what the heck does this guy do?
};
//==============================================================================
// This macro generates the main() routine that launches the app.
START_JUCE_APPLICATION (MyApplication) // This guy generates the entry point?