🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

1 total messages Started by Bjarne Stroustrup Sat, 22 Feb 1986 13:57
cfront working too hard?
#21
Author: Bjarne Stroustrup
Date: Sat, 22 Feb 1986 13:57
48 lines
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)
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads