(ref.doc)bs 021194

Next egb 121294 Prev: maxtal 270894 Up: Usenet

Newsgroups: comp.lang.c++
From: [email protected] (Bjarne Stroustrup <9758-26353> 0112760)
Date: Wed, 2 Nov 1994 16:58:59 GMT

[...]

derived::f(int) hides base::f(int,int) so you get

	void g(base* pb, derived* pd)
	{
		pb->f(1);	// ok
		pb->f(1,2);	// ok

		pd->f(1);	// ok
		pd->f(1,2);	// error
	}

A compiler can warn you about the hiding, and some compilers do.

The upcoming standard provides a way of making otherwise hidden base
class functions available in a derived class without re-implementing
them. For example:

	class base {
		// ...
		virtual void f(int i);
		virtual void f(int i, int j);
	};

	class derived {
	public:
		virtual void f(int i); // override base::f(int)
		using base::f;         // make other f's available
	};

Now derived overrides base::f(int) and inherits base::f(int,int)
as is so all of the calls in g() above will work. For more detail,
see Stroustrup: ``The Design and Evolution of C++'' sec17.5. 

	- Bjarne

automatically generated by info2www version 1.2.2.8