Search code examples
c++qtc++11qt-creatorshared-ptr

qt application and std::shared_ptr


I want to create a qt application ( using qt-creator ), that use my library, that was build in VS2010. A library contains a class, that use std::shred_ptr<>

#include <memory>
struct MyStruct;

class MyClass
{
    public:
    MyClass::MyClass();

    protected:
    std::shared_ptr<MyStruct> mMember;
}

Then I include library to the application, using This tutorial. And gets next errors:

ISO C++ forbids declaration of 'shared_ptr' with no type
invalid use of '::'
expected ';' before '<' token

Is a way to solve this problem?

*PS*Was corrected code( added include and parameter class of shared_ptr ). But this things already been in original code. I think, the problem in the qt-creator compiler. But I don't know exactly, because I'm pretty new in qt programming.


Solution

  • Make sure you use C++11 flag for compiler. For example, in your .pro-file:

    QMAKE_CXXFLAGS += -std=c++0x