How can I test out header files and related C++ source code?



  • I try to add new function for my Qt program with CPP and header file. But I'm not quite sure if I get it right. Like to test it out on Qt Creator, but errors and warnings keeps popping up. I don't know what I I've done wrong.

    header:

    #include <QApplication>
    #include <QObject>
    #include <QWidget>
    #include <QString>
    #include <iostream>

    #ifndef TEST_H
    #define TEST_H

    class test{
    public:
    static bool check(const QString& data);
    static void run;
    public:
    static unsigned char* pTr = NULL;
    }


  • Qt Champions 2017

    Hi and welcome.

    I added some comment to the code to show the changes to make it compile.

    I wonder if you are aware of using static in classes has a completely other meaning than
    in good old C.
    http://www.tutorialspoint.com/cplusplus/cpp_static_members.htm
    :)

    #ifndef TEST_H
    #define TEST_H
    class test{
    public:
    static bool check(const QString& data);
    static void run(); <------------- must have () when function
    public:
    static unsigned char* pTr = NULL;
    }; <---- must end with ;
    #endif <----- was missing
    

  • Moderators

    @rogerloh4.0 said:

    errors and warnings keeps popping up. I don't know what I I've done wrong.

    Read the error messages. They tell you what's wrong.



  • @mrjj No, I didn't know that, thanks for pointing my errors out. :)


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.