Basically I have a class that has multiple QString values, a constructor, and a method. The object gets it's 'values' set in the constructor. Then I need to call the method, toString()
using the object to return the assigned value. How can I do this as when I try I get invalid use of non-static data member 'DisconnectReason::BANNED'
. Any help is greatly appreciated!
Class:
class DisconnectReason
{
public:
QString BANNED = "B&";
QString IDLE_TIMEOUT = "it";
QString KICKED = "k";
QString MANUAL = "man";
QString PING_TIMEOUT = "pt";
QString reason;
DisconnectReason(const QString reason)
{
this->reason = reason;
}
public:
virtual QString toString()
{
return reason;
}
};
Interface.cpp
#include "interface.h"
#include "ui_interface.h"
#include <QDebug>
#include "constants.h"
Interface::Interface(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::Interface)
{
ui->setupUi(this);
DisconnectReason *dr = new DisconnectReason(DisconnectReason::BANNED);//Error here
qDebug() << dr->toString();
}
Interface::~Interface()
{
delete ui;
}