Results 1 to 3 of 3

Thread: Error message in object pointer definition. Don't know what means.

  1. #1
    Join Date
    Mar 2015
    Posts
    105
    Thanks
    50

    Default Error message in object pointer definition. Don't know what means.

    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:
    Qt Code:
    1. class Data : public QDialog
    2. {
    3. //...
    4. public:
    5. Historic *hs = NULL; Message error here.
    To copy to clipboard, switch view to plain text mode 

    Thanks!

  2. #2
    Join Date
    Dec 2009
    Location
    New Orleans, Louisiana
    Posts
    791
    Thanks
    13
    Thanked 153 Times in 150 Posts
    Qt products
    Qt5
    Platforms
    MacOS X

    Default Re: Error message in object pointer definition. Don't know what means.

    You should use initializer lists for member parameter initialization:

    Qt Code:
    1. class Data : public QDialog, hs(NULL)
    2. {
    3. //...
    4. public:
    5. Historic *hs;
    To copy to clipboard, switch view to plain text mode 

    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.

  3. #3
    Join Date
    Feb 2012
    Location
    Warsaw, Poland
    Posts
    37
    Thanks
    3
    Thanked 6 Times in 6 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows Android

    Default Re: Error message in object pointer definition. Don't know what means.

    To use this feature you need to enable C++11.

    Qt Code:
    1. CONFIG += c++11
    2. or
    3. QMAKE_CXXFLAGS += -std=c++11
    To copy to clipboard, switch view to plain text mode 
    in your .pro file.

    Other way: set pointer in constructor.

Similar Threads

  1. QT Application gives Multiple Definition Link Error
    By behlkush in forum Qt Programming
    Replies: 4
    Last Post: 10th March 2015, 03:52
  2. Replies: 2
    Last Post: 12th December 2013, 14:25
  3. Replies: 2
    Last Post: 5th September 2013, 11:47
  4. what`s means this Error Message?
    By blm in forum Qt Programming
    Replies: 2
    Last Post: 15th September 2008, 16:58
  5. Getting multiple definition error from qatomic_x86_64.h
    By markcole in forum General Programming
    Replies: 1
    Last Post: 30th August 2007, 19:39

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.