Reputation: 2281
When I have defined fnc in a following way:
QDialog* get_dialog(Caller* caller);
then calling it with my class
class Main_Dialog : public Base_Dialog<Ui::Main_Dialog>{};
works.
//def of Base_Dialog
template< class Ui_Dialog >
class Base_Dialog : public QDialog, protected Ui_Dialog{};
but if I define this fnc as:
QDialog* get_dialog(Caller*& caller); //note ref
then code doesn't compile, giving error:
error: no matching function for call to 'Main_Dialog::get_dialog(Main_Dialog* const)'
candidate is:
template<class Dialog, class Caller> QDialog* Main_Dialog::get_dialog(Caller*&)
Isn't that the fnc I'm trying to call? What's wrong?
Upvotes: 0
Views: 157
Reputation: 76788
It looks like you are trying to pass in a const
pointer, but the method requires a non-const
pointer.
QDialog* get_dialog(Caller*& caller);
This method requires a reference to a pointer (no const
anywhere). If you would pass in a non-const
pointer, it would implicitly be converted to a reference-to-non-const
-pointer. However, if you are passing in a const
-pointer, that implicit conversion does not work, so the compiler looks for a function with a signature like:
get_dialog(Main_Dialog* const)
Upvotes: 1