PDA

View Full Version : Error message in object pointer definition. Don't know what means.



robgeek
18th April 2015, 16:36
Good day!

What means the following error message and how can i fix it? I'm using QtCreator-5.3.2 with GCC-4.6.1 64bit.


warning: non-static data member initializers only available with -std=c++11 or -std=gnu++11 [enabled by default]

Error pointing to this code line:

class Data : public QDialog
{
//...
public:
Historic *hs = NULL; Message error here.

Thanks!

jefftee
18th April 2015, 17:47
You should use initializer lists for member parameter initialization:



class Data : public QDialog, hs(NULL)
{
//...
public:
Historic *hs;


Edit: And yes, you should also add c++11 to your CONFIG statement in your *.pro file too to enable the c++11 standard for many different reasons.

west
18th April 2015, 17:48
To use this feature you need to enable C++11.



CONFIG += c++11
or
QMAKE_CXXFLAGS += -std=c++11

in your .pro file.

Other way: set pointer in constructor.