Solange ich nun darauf gewartet habe, freigeschaltet zu werden, plagt mich schon ein gewisses Problem. Ich habe es eben nochmal versucht abstrakt aus meinem Projekt heraus zu arbeiten, so dass es hoffentlich noch verständlich und auch reproduzierbar ist. Schauen wir uns also den Code an:
Code: Alles auswählen
#include <QCoreApplication>
#include <QDebug>
struct config {
short id;
short sno;
};
Code: Alles auswählen
class o_Config
{
private:
struct config *_structure;
public:
explicit o_Config(struct config *cfg):
_structure()
{ _structure = cfg; }
struct config *getStruct()
{ return _structure; }
};
Code: Alles auswählen
class o_Device
{
private:
o_Config *_cfg;
void init()
{
readCfg();
}
void readCfg()
{
struct config cfg;
cfg.id = 1;
cfg.sno = 123;
struct config *cfgPntr = &cfg;
_cfg = new o_Config(cfgPntr);
}
public:
explicit o_Device():
_cfg()
{ init(); }
struct config *getCfgStruct()
{ return _cfg->getStruct(); }
};
Code: Alles auswählen
int main(int argc, char *argv[])
{
QCoreApplication a(argc, argv);
o_Device* o_dev = new o_Device();
struct config* myCfg = o_dev->getCfgStruct();
qDebug() << "id:" << myCfg->id;
qDebug() << "sno:" << myCfg->sno;
return a.exec();
}
Grüße,id: 1
sno: 34
leif