member initialization - no matching function - candidates are

J

Jeff

Its been years since I did C++ and Im unsure what this is about.

I have a QT class Im inheriting from in my .h file:

class Mosfet : Q3CanvasRectangle
{
public:
Mosfet::Mosfet(const QRect &qr, Q3Canvas *canvas);
Mosfet::~Mosfet();

....etc
};

In my .cpp file I have:

Mosfet::Mosfet(const QRect &qr, Q3Canvas *canvas) :
Q3CanvasRectangle(canvas)
{
}


When I compile I get:
Mosfet.cpp: In constructor 'Mosfet::Mosfet(const QRect&,
Q3Canvas*)':
Mosfet.cpp:13: error: no matching function for call to
'Q3CanvasRectangle::Q3CanvasRectangle()'
/opt/qt41/include/Qt/q3canvas.h:565: note: candidates are:
Q3CanvasRectangle::Q3CanvasRectangle(int, int, int, int, Q3Canvas*)
/opt/qt41/include/Qt/q3canvas.h:564: note:
Q3CanvasRectangle::Q3CanvasRectangle(const QRect&, Q3Canvas*)
/opt/qt41/include/Qt/q3canvas.h:563: note:
Q3CanvasRectangle::Q3CanvasRectangle(Q3Canvas*)
/opt/qt41/include/Qt/q3canvas.h:561: note:
Q3CanvasRectangle::Q3CanvasRectangle(const Q3CanvasRectangle&)

My question is, why does the compiler say that there is no matching
function:
Mosfet.cpp:13: error: no matching function for call to
'Q3CanvasRectangle::Q3CanvasRectangle()'

when my initializer list is clearly Q3CanvasRectangle(canvas) ?

It appears to me it doesnt like my init list and is calling a default
ctor,
which of course isnt in the candidates list.

Can someone point out the err in my ways? :)
Thanks,
Jeff

PS using fedora core 4, gcc version 4.0.2 20051125 (Red Hat 4.0.2-8)
QT 4.1
 
V

Victor Bazarov

Jeff said:
Its been years since I did C++ and Im unsure what this is about.

I have a QT class Im inheriting from in my .h file:

class Mosfet : Q3CanvasRectangle

Privately inherited? Just checking...
{
public:
Mosfet::Mosfet(const QRect &qr, Q3Canvas *canvas);
Mosfet::~Mosfet();

...etc
};

In my .cpp file I have:

Mosfet::Mosfet(const QRect &qr, Q3Canvas *canvas) :
Q3CanvasRectangle(canvas)
{
}


When I compile I get:
Mosfet.cpp: In constructor 'Mosfet::Mosfet(const QRect&,
Q3Canvas*)':
Mosfet.cpp:13: error: no matching function for call to
'Q3CanvasRectangle::Q3CanvasRectangle()'

Which line is '13'?
/opt/qt41/include/Qt/q3canvas.h:565: note: candidates are:
Q3CanvasRectangle::Q3CanvasRectangle(int, int, int, int, Q3Canvas*)
/opt/qt41/include/Qt/q3canvas.h:564: note:
Q3CanvasRectangle::Q3CanvasRectangle(const QRect&, Q3Canvas*)
/opt/qt41/include/Qt/q3canvas.h:563: note:
Q3CanvasRectangle::Q3CanvasRectangle(Q3Canvas*)
/opt/qt41/include/Qt/q3canvas.h:561: note:
Q3CanvasRectangle::Q3CanvasRectangle(const Q3CanvasRectangle&)

My question is, why does the compiler say that there is no matching
function:
Mosfet.cpp:13: error: no matching function for call to
'Q3CanvasRectangle::Q3CanvasRectangle()'

when my initializer list is clearly Q3CanvasRectangle(canvas) ?

Are you sure it's the part of the initialiser list that your compiler is
complaining about?
It appears to me it doesnt like my init list and is calling a default
ctor,
which of course isnt in the candidates list.

Could it be that you also have a member of that type? Read FAQ 5.8.
Can someone point out the err in my ways? :)

As soon as you supply enough information.
Thanks,
Jeff

PS using fedora core 4, gcc version 4.0.2 20051125 (Red Hat 4.0.2-8)
QT 4.1

That's irrelevant.

V
 
I

Ian Collins

Jeff said:
Its been years since I did C++ and Im unsure what this is about.

when my initializer list is clearly Q3CanvasRectangle(canvas) ?
Does Q3CanvasRectangle have such a constructor?
 
J

Jeff

Does Q3CanvasRectangle have such a constructor?

yes.

I just found the problem. I had a leftover Q3CanvasRectangle
in my private area. UGH

Thanks guys
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,767
Messages
2,569,572
Members
45,045
Latest member
DRCM

Latest Threads

Top