Article View: net.lang.c++
Article #21cfront working too hard?
From: Bjarne Stroustrup
Date: Sat, 22 Feb 1986 13:57
Date: Sat, 22 Feb 1986 13:57
48 lines
2128 bytes
2128 bytes
> 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)
Technical Details
Message-ID:
<5018@alice.uUCp>Path:
arc1-ca.pugleaf.net!utzoo!linus!decvax!bellcore!ulysses!allegra!alice!bsShow Full Headers
Complete Article Headers
Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.1 6/24/83; site alice.UUCP Path: arc1-ca.pugleaf.net!utzoo!linus!decvax!bellcore!ulysses!allegra!alice!bs From: bs@alice.UucP (Bjarne Stroustrup) Newsgroups: net.lang.c++ Subject: cfront working too hard? Message-ID: <5018@alice.uUCp> Date: Sat, 22-Feb-86 08:57:23 EST Article-I.D.: alice.5018 Posted: Sat Feb 22 08:57:23 1986 Date-Received: Mon, 24-Feb-86 08:31:26 EST Organization: Bell Labs, Murray Hill Lines: 48