Variable initialised in Constructor is null , but initialised in class method works
Solution 1:
For reference this is what user17732522 is referring to
#include "zmqworker.h"
#include <QDebug>
ZMQWorker::ZMQWorker(QObject *parent)
: QObject{parent},
sock(ctx, zmq::socket_type::dealer)
{
qDebug() << "Dealer Socket created";
}
void ZMQWorker::connectSocket()
{
std::string origin="CPP_ZMQ";
sock.connect("tcp://127.0.0.1:5555");
qDebug() << "Dealer Socket connected";
}