kernco
July 6th, 2010, 09:13 PM
I'm having trouble fixing a compile error I'm getting. I'm using the Qt library, and in my project I've subclassed QVector2D with my own Vector class. Another class I have, Foo, has this constructor:
Foo(const Vector &, qreal, Bar*)
The error comes when I try to instantiate one of them like this:
foo = new Foo(Vector(1, 0.3).normalized(), 1, this);
I get the error
no matching function for call to ‘Foo::Foo(QVector2D, int, Bar* const)’
candidates are: Foo::Foo(Vector, qreal, Bar*)
Foo::Foo(const Foo&)
The normalized() function returns a QVector2D, but since Vector inherits QVector2D, shouldn't it work? Is there some type of copy constructor I need to write? I also notice that it looks like I'm trying to pass a "Bar* const" to the constructor, but it takes "Bar*". I don't think this is the source of the error, since I'd expect a "discards qualifiers" error if it was.
Foo(const Vector &, qreal, Bar*)
The error comes when I try to instantiate one of them like this:
foo = new Foo(Vector(1, 0.3).normalized(), 1, this);
I get the error
no matching function for call to ‘Foo::Foo(QVector2D, int, Bar* const)’
candidates are: Foo::Foo(Vector, qreal, Bar*)
Foo::Foo(const Foo&)
The normalized() function returns a QVector2D, but since Vector inherits QVector2D, shouldn't it work? Is there some type of copy constructor I need to write? I also notice that it looks like I'm trying to pass a "Bar* const" to the constructor, but it takes "Bar*". I don't think this is the source of the error, since I'd expect a "discards qualifiers" error if it was.