Article View: comp.std.c++
Article #434Using return datum type in function signature
From: Kurt Stephens
Date: Thu, 30 Aug 1990 23:55
Date: Thu, 30 Aug 1990 23:55
45 lines
1706 bytes
1706 bytes
Why isn't the return datum type used in the construction of
a function signature? Would it be helpful to have overloaded
with the same argument signatures but different return types?
For example:
1 class Foo;
2 class Bar;
3 class Tickle { // couldn't think of a better name ;^)
4 Foo f;
5 Bar b;
6 public:
7 Foo Get( void ) { return f; } // note the different
8 Bar Get( void ) { return b; } // return types
9 };
10
11 main() {
12 Foo f;
13 Bar b;
14 Tickle t;
15
16 f = t.Get(); // would call Foo Tickle::Get( void )
17 b = t.Get(); // would call Bar Tickle::Get( void )
19 }
Is this impossible because the call to Get() can only
be disambiguated by examining the surrounding context?
Could, the assignment (in line 16) be interpreted as
"assign Foo f with the value of Foo Tickle T::Get()" obviously?
If this is possible what would happen if there were cast
operators between classes Foo and/or Bar? Example:
Foo::operator Bar ( void ) { /* something */ }
Bar::operator Foo ( void ) { /* something */ }
Would this make the expression "f = t.Get();" ambigous again?
I don't really know if this is feasable or useful; I'm just asking.
(i.e. Be gentle with me.)
--
Kurt A. Stephens
...!uunet!motcid!stephens
Technical Details
Message-ID:
<4335@celery34.UUCP>Path:
arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!uunet!motcid!stephensShow Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!uunet!motcid!stephens From: stephens@motcid.UUCP (Kurt Stephens) Newsgroups: comp.std.c++,comp.lang.c++ Subject: Using return datum type in function signature Keywords: c++,signature Message-ID: <4335@celery34.UUCP> Date: 30 Aug 90 23:55:33 GMT Distribution: comp Organization: Motorola Inc., Cellular Infrastructure Div., Arlington Heights, IL Lines: 45