Menu

the class "" does not declare a constructor although it has private member variables which likely require initialization

DarrenSong
2022-07-01
2022-07-06
  • DarrenSong

    DarrenSong - 2022-07-01

    i conform that i declare a constructor in the class, but it still report this error that does not declare a constructor.
    pls see the detail below:
    class AMS_DMS : public IDMS2<--- The class 'AMS_DMS' does not declare a constructor although it has private member variables which likely require initialization. [+]
    {
    public:
    IMPLEMENT_AXISBASE_NAME("AMS_URANUS80")

    AMS_DMS();
    virtual ~AMS_DMS();
    }

     
  • DarrenSong

    DarrenSong - 2022-07-01

    anyone else who can tell me what should i do in this case?

     
  • DarrenSong

    DarrenSong - 2022-07-01

    cppcheck version is v2.8

     
  • CHR

    CHR - 2022-07-01

    Posting sufficient code to actually reproduce the problem would be helpful.
    I don't get a warning for

    class AMS_DMS : public IDMS2
    {
        public:
        IMPLEMENT_AXISBASE_NAME("AMS_URANUS80")
    
        AMS_DMS();
        virtual ~AMS_DMS();
    };
    
     
  • DarrenSong

    DarrenSong - 2022-07-06

    i try to change the code as below,it do not report this error.
    class AMS_DMS : public IDMS2
    {
    public:

    AMS_DMS();
    virtual ~AMS_DMS();
    

    IMPLEMENT_AXISBASE_NAME("AMS_URANUS80")
    };

     
  • Daniel Marjamäki

    It is often hard to reproduce by writing code from scratch because there might be some non-obvious detail in your code that confuses Cppcheck.

    Can you please try to reduce your original code instead. Start with all the code that generates the warning. Then remove piece-by-piece from the file and every time check if cppcheck still writes such complaint.
    I would start removing large chunks. Remove a large chunk of code that you think is not necessary to reproduce the false positive. If the false positive goes away then undo in the editor and try removing something else..

     

    Last edit: Daniel Marjamäki 2022-07-06

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.