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.
Make sure you use C++11 flag for compiler. For example, in your .pro -file:
QMAKE_CXXFLAGS += -std=c++0x
There's no definition of MyClass2
int the code you shared.
I believe you were trying to do std::shared_ptr<MyClass> mMember;
Include <memory>
before defining the class. Also make sure MyClass2
is declared.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.