L
Lionel B
Hi,
I am vexed by the following behaviour:
struct Base
{
int i;
void func(int i_)
{
i = i_;
}
};
struct Derived : Base
{
int j;
void func(int i_, int j_)
{
i = i_;
j = j_;
}
};
int main()
{
Derived x;
x.func(3);
}
My compiler tells me:
scratch.cpp:26: error: no matching function for call to ‘Derived::func(int)’
scratch.cpp:15: note: candidates are: void Derived::func(int, int)
If the definition of Derived::func(int, int) is commented out the code
compiles ok.
What puzzles me is that the signatures of Base::func(int) and
Derived::func(int, int) are different; so if the compiler fails to find a
match for Derived::func(int), why does it not match Base::func(int), as
it will if Derived::func(int, int) is not present?
I am vexed by the following behaviour:
struct Base
{
int i;
void func(int i_)
{
i = i_;
}
};
struct Derived : Base
{
int j;
void func(int i_, int j_)
{
i = i_;
j = j_;
}
};
int main()
{
Derived x;
x.func(3);
}
My compiler tells me:
scratch.cpp:26: error: no matching function for call to ‘Derived::func(int)’
scratch.cpp:15: note: candidates are: void Derived::func(int, int)
If the definition of Derived::func(int, int) is commented out the code
compiles ok.
What puzzles me is that the signatures of Base::func(int) and
Derived::func(int, int) are different; so if the compiler fails to find a
match for Derived::func(int), why does it not match Base::func(int), as
it will if Derived::func(int, int) is not present?