Thread View: comp.std.c++
3 messages
3 total messages
Started by Claus A. Faerber
Mon, 05 Feb 1996 22:59
Re: Give operator. a chance
Author: Claus A. Faerber
Date: Mon, 05 Feb 1996 22:59
Date: Mon, 05 Feb 1996 22:59
51 lines
1878 bytes
1878 bytes
IMO there's a better way than 'operator.()':
Simply say: 'If a class member identifier is not found
within an object, all possible cast operators are scanned in
order to find a conversion to an object of a class
containing a member with this identifier.'
Eg.:
class A{
public: void A();
void C();
}
class B{
public:
void B();
void C();
void D();
}
class C{
A* pA;
B* pB;
public:
void D();
A& operator A&() { return *pA; };
B& operator B&() { return *pB; };
}
//
C c;
c.A(); // calls ((A&)c).A();
c.B(); // calls ((B&)c).B();
c.C(); // calls ((A&)c).C();, as operator A& is first
c.D(); // calls c.D();, as D() is already member of C
Claus
------------------------------------------------------------------------
Claus Andre Faerber - claus@faerber.muc.de - http://www.muc.de/~cfaerber
------------------------------------------------------------------------
---
[ comp.std.c++ is moderated. Submission address: std-c++@ncar.ucar.edu.
Contact address: std-c++-request@ncar.ucar.edu. The moderation policy is
in http://reality.sgi.com/employees/austern_mti/std-c++/policy.html. ]
Re: Give operator. a chance
Author: Andrew Koenig
Date: Tue, 06 Feb 1996 14:42
Date: Tue, 06 Feb 1996 14:42
18 lines
1290 bytes
1290 bytes
In article <62HLdPo3cDB@faerber.muc.de> claus@faerber.muc.de (Claus A. Faerber) writes: > IMO there's a better way than 'operator.()': > Simply say: 'If a class member identifier is not found > within an object, all possible cast operators are scanned in > order to find a conversion to an object of a class > containing a member with this identifier.' I suspect that makes compilation impossibly hard in the presence of templates. -- --Andrew Koenig ark@research.att.com --- [ comp.std.c++ is moderated. Submission address: std-c++@ncar.ucar.edu. Contact address: std-c++-request@ncar.ucar.edu. Moderation policy: http://reality.sgi.com/employees/austern_mti/std-c++/policy.html. ]
Re: Give operator. a chance
Author: Jerry Coffin
Date: Fri, 09 Feb 1996 00:18
Date: Fri, 09 Feb 1996 00:18
14 lines
1277 bytes
1277 bytes
claus@faerber.muc.de (Claus A. Faerber) wrote: >IMO there's a better way than 'operator.()': >Simply say: 'If a class member identifier is not found >within an object, all possible cast operators are scanned in >order to find a conversion to an object of a class >containing a member with this identifier.' Which would be chosen if two or more possibilities would work? --- [ comp.std.c++ is moderated. Submission address: std-c++@ncar.ucar.edu. Contact address: std-c++-request@ncar.ucar.edu. The moderation policy is in http://reality.sgi.com/employees/austern_mti/std-c++/policy.html. ]
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