Accessing (partially) overloaded function

Consider the code:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
class Base
{
	// Declares two versions of foo

	public:
	void foo (void)
	{}

	public:
	void foo (int i)
	{}
};

class Derived : public Base
{
	// Overloads the first version of foo in the base class

	public:
	void foo (void)
	{}
};

int main (void)
{
	Derived o;
	o.foo (0); // cannot access foo (int) from Base
}


It generates the following compilation error:

1
2
3
main.cxx: In function ‘int main()’:
main.cxx:22: error: no matching function for call to ‘Derived::foo(int)’
main.cxx:15: note: candidates are: void Derived::foo()


If there any way to overload only one version of a polymorphic function in the derived class, and able to call all other un-overloaded versions from the base class?
Those functions are not polymorphic ( they weren't declared virtual )
If this non-polymorphic behaviour is what you intended, try adding using Base::foo; in the derived class
+1 for Bazzy's solution

Also to add, using Base::foo; should go in the public section of Derived, or the foo overloads from Base will be inaccessible for main.

Regards
Thanks. The using Base::foo; is cool :)
Topic archived. No new replies allowed.