Dear all,
Could someone please explain what I am doing wrong below, and why this is not working?
Thanks!
In a dynamic library i have a class LibObject that has a static function createObject() which returns an instance of itself:
class LibObject
{
private:
int a;
public:
LibObject();
static LibObject createObject(); // the LibObject factory
int getA();
void setA(int i);
}
LibOjcect::LibObject() {}
LibObject LibObject::createObject() { // the LibObject factory
LibObject o;
return o;
}
int LibObject::getA() { return a }
void LibObject::setA(int i) { a = i }
class LibObject
{
private:
int a;
public:
LibObject();
static LibObject createObject(); // the LibObject factory
int getA();
void setA(int i);
}
LibOjcect::LibObject() {}
LibObject LibObject::createObject() { // the LibObject factory
LibObject o;
return o;
}
int LibObject::getA() { return a }
void LibObject::setA(int i) { a = i }
To copy to clipboard, switch view to plain text mode
Now in another class Object I am extending the LibObjectclass:
class Object : public LibObject
{
public:
Object();
}
Object::Object() {}
class Object : public LibObject
{
public:
Object();
}
Object::Object() {}
To copy to clipboard, switch view to plain text mode
Ok. So, now a third class would like to add Object objects to a QList:
class Test
{
private:
QList<Object> objects;
public:
Test();
}
Test::Test()
{
objects.append(Object::createObject());
}
class Test
{
private:
QList<Object> objects;
public:
Test();
}
Test::Test()
{
objects.append(Object::createObject());
}
To copy to clipboard, switch view to plain text mode
At compile time I get this error:
error: no matching function for call to 'QList<Object>::append(LibObject)'
So, is the static function createObject() not copied to the Object declaration?
Bookmarks