PDA

View Full Version : class constructor



^NyAw^
5th December 2008, 17:16
Hi,

I have a class like that:



class A
A(QHash<QSrting,QVariant>); //Constructor


But the compiler is getting me "class without constructors" when trying to create a "A" class object.

Wich is the problem? I'm able to use a constrctor getting an "int" as parameter but it seems to not like the QHash parameter?

Thanks,

spirit
5th December 2008, 17:37
works fine for me


#include <QHash>
#include <QVariant>

class A
{
public:
A(QHash<QString, QVariant> &hash) : m_hash(hash) {}

private:
QHash<QString, QVariant> m_hash;
};

...
QHash<QString, QVariant> h;
A a(h);
...

^NyAw^
5th December 2008, 18:25
Hi,

Ups, just a mistake on inheritance.

Thanks,