D
Dan Noland
I can work around this easily enough, but can someone help me
understand why this works as it does? It seems that functions from a
grandparent class are not available as candidates for overload
resolution in the grandchild class?
/***** Begin Example *****/
#include <iostream>
class Foo
{
public:
void somefunc(int a);
};
class Bar: public Foo
{
public:
void somefunc(int a, int b);
};
class Baz: public Bar
{
public:
void broken();
};
void Foo::somefunc(int a)
{
std::cout << "somefunc 1 arg: " << a << std::endl;
return;
}
void Bar::somefunc(int a, int b)
{
std::cout << "somefunc 2 args: " << a << ", " << b << std::endl;
return;
}
void Baz::broken()
{
int arg = 555;
// Foo::somefunc(arg); <-- This works
somefunc(arg); // <-- Why doesn't this work?
return;
}
int main(int argc, char** argv)
{
class Baz tmp;
tmp.broken();
return(0);
}
/***** Begin Example *****/
understand why this works as it does? It seems that functions from a
grandparent class are not available as candidates for overload
resolution in the grandchild class?
/***** Begin Example *****/
#include <iostream>
class Foo
{
public:
void somefunc(int a);
};
class Bar: public Foo
{
public:
void somefunc(int a, int b);
};
class Baz: public Bar
{
public:
void broken();
};
void Foo::somefunc(int a)
{
std::cout << "somefunc 1 arg: " << a << std::endl;
return;
}
void Bar::somefunc(int a, int b)
{
std::cout << "somefunc 2 args: " << a << ", " << b << std::endl;
return;
}
void Baz::broken()
{
int arg = 555;
// Foo::somefunc(arg); <-- This works
somefunc(arg); // <-- Why doesn't this work?
return;
}
int main(int argc, char** argv)
{
class Baz tmp;
tmp.broken();
return(0);
}
/***** Begin Example *****/