Article View: gnu.g++
Article #439c++ question
From: Jason Venner
Date: Tue, 16 May 1989 06:11
Date: Tue, 16 May 1989 06:11
41 lines
1400 bytes
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
Technical Details
Message-ID:
<1886.611302275@kadmon>Path:
arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!tut.cis.ohio-state.edu!MTXINU.COM!kadmon!jasonShow Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!tut.cis.ohio-state.edu!MTXINU.COM!kadmon!jason From: kadmon!jason@MTXINU.COM (Jason Venner) Newsgroups: gnu.g++ Subject: c++ question Message-ID: <1886.611302275@kadmon> Date: 16 May 89 06:11:15 GMT Sender: daemon@tut.cis.ohio-state.edu Distribution: gnu Organization: GNUs Not Usenet Lines: 41