mat@mtx5a.UUCP (m.terribile) (02/20/86)
In compiling a base class b with virtual function v, I declare
virtual int
b::v( b* bp )
{
return 0;
}
where the intent is that derived classes may have good use for bp, but
the base class represents a null case.
cfront naturally warns about the unused argument.
Is this excessive in the case of a virtual function? Is there
a syntax (such as omitting ``bp'') that will allow me to say ``I know
that an argument is passed, but I don't need it'' ? With virtuals, this
might be a common situation.
As usual, if this could better have been handled by private mail,
sill someone please let me know?
Mark T.
--
from Mole End Mark Terribile
(scrape .. dig ) mtx5b!mat
(Please mail to mtx5b!mat, NOT mtx5a!
mat, or to mtx5a!mtx5b!mat)
,.. .,, ,,, ..,***_*.
bs@alice.UucP (Bjarne Stroustrup) (02/22/86)
> From: mat@mtx5a.UUCP (m.terribile) > Newsgroups: net.lang.c++ > Subject: cfront working too hard? > Organization: AT&T Information Systems, Middletown, NJ 07748-4801. > > In compiling a base class b with virtual function v, I declare > > virtual int > b::v( b* bp ) > { > return 0; > } > > where the intent is that derived classes may have good use for bp, but > the base class represents a null case. > > cfront naturally warns about the unused argument. > > Is this excessive in the case of a virtual function? Is there > a syntax (such as omitting ``bp'') that will allow me to say ``I know > that an argument is passed, but I don't need it'' ? With virtuals, this > might be a common situation. You need not give an argument a name if you don't use it: virtual int b::v(b*) { return 0; } This is occationally also useful for non-virtual functions. The typical reason is that an argument is not yet used but is a part some agreed upon interface. It can also happen the other way: an argument used to be needed, but then you find a way of doing without it. Leaving the argument unused and unnamed rather than removing it leaves the ``official'' interface unchanged. > As usual, if this could better have been handled by private mail, > sill someone please let me know? As I see it, there are so many people that are new to C++ that most sensible questions deserve an answer on the net: If you had a problem, someone else very likely had it too. > > from Mole End Mark Terribile > (scrape .. dig ) mtx5b!mat - Bjarne Stroustrup (AT&T Bell Labs, Murray Hill)