how to declare global (static?) function inside class?
Solved
C++ Gurus
-
Hi all -
I have a class with a member function that I'd like to use without having to instantiate an object of the class. I've never done this before, but this is what I tried:
#pragma once #include <QObject> #include <QQmlEngine> class Clock : public QObject { Q_OBJECT QML_ELEMENT public: explicit Clock(QObject *parent = nullptr); static bool m_use24hourTime; static QString getTimeString(QTime time); } };
I get a link error:
undefined reference to `Clock::m_use24hourTime'
so I'm obviously doing something wrong. I do use that variable in other routines in the class.
Can someone tell me what I'm doing wrong here?
Thanks...
-
@mzimmers said in how to declare global (static?) function inside class?:
so I'm obviously doing something wrong
You just declare the variable but don't define them anywhere.
-