🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

1 total messages Started by Jason Venner Tue, 16 May 1989 06:11
c++ question
#439
Author: Jason Venner
Date: Tue, 16 May 1989 06:11
41 lines
1400 bytes
I have some code that operates on a class.

(it is actually a class (B)that as a private data element that is an
instance of a class (A)).

In the code, I want to call a member function of of A.
This is an overloaded function, and can be called with either a char
or a char*.

In Class B, I would like to call it sometimes with a char, and
sometimes with a Chars.  The code that does it is almost identical.

How can I do this in g++ with only one function.

I could do it with macro's, but that seems to be frowned upon in
G++ing circles.  


What I want is
     member put(char c)		{ return internal_magic_put( c ); };
     member put( char* s)	{ return internal_magic_put( c ); };
...

internal_magic_put( char or char* thing, thing is a char or thing is a
char* )
{

	A::put(thing);		// automagically the correct type
	passed
	if( is a char ) do x
	else
		do y
.....

Jason Venner
Jason@spar.stanford.edu
jason@mtxinu.com
jason@violet.berkeley.edu
jason@ucbviolet.bitnet
{...,ucbvax}!mtxinu!jason
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