ScopedPointer private member


#1

This code compiles on Window but fails on Linux:

int main (int argc, char* argv[])
{

    // ..your code goes here!
        ScopedJuceInitialiser_GUI plattform;
        ScopedPointer <MyClass> myClass = new MyClass();
        MessageManager::getInstance()->runDispatchLoop();
    return 0;
}

The error is:

Compiling Main.cpp
In file included from ../../Source/../JuceLibraryCode/modules/juce_audio_basics/../juce_core/juce_core.h:190:0,
                 from ../../Source/../JuceLibraryCode/modules/juce_audio_basics/juce_audio_basics.h:28,
                 from ../../Source/../JuceLibraryCode/JuceHeader.h:17,
                 from ../../Source/Main.cpp:11:
../../Source/../JuceLibraryCode/modules/juce_audio_basics/../juce_core/memory/juce_ScopedPointer.h: In function 'int main(int, char**)':
../../Source/../JuceLibraryCode/modules/juce_audio_basics/../juce_core/memory/juce_ScopedPointer.h:223:5: error: 'juce::ScopedPointer<ObjectType>::ScopedPointer(const juce::ScopedPointer<ObjectType>&) [with ObjectType = MyClass; juce::ScopedPointer<ObjectType> = juce::ScopedPointer<MyClass>]' is private
../../Source/Main.cpp:33:48: error: within this context
make: *** [build/intermediate/Debug/Main_90ebc5c2.o] Error 1

EDIT:

but this seems to fix it, i don't know if the first method is wrong:

ScopedPointer <MyClass> myClass (new MyClass());
        MessageManager::getInstance()->runDispatchLoop();
    return 0;

#2

You should use the bracketed initialiser unless you've got C++11 support. Technically it's a mistake for the MS compiler to allow it to compile.