Casting vs. operator overloading

From: Anand Hariharan (desh_bakth_at_yahoo.com)
Date: 03/31/04


Date: 31 Mar 2004 09:36:34 -0800

Do the semantics of -

    (T) MyObj

or

    XXX_cast<T> MyObj

(where XXX is static/dynamic/reinterpret/...) have anything to do with
-

    MyObj.operator T()

?

If it does not, is there any way by which I could prevent clients of
my class from casting its instances to another type, and/or delegate
such code to the overloaded operator?

The solutions that I am aware of are -
 * Talk to them or get them to talk to you.
 * Implement member functions to do what they are really after.
 * Document your interfaces.
None of them really are *LANGUAGE* solutions! :(

thank you for listening,
- Anand Hariharan



Relevant Pages

  • Re: object system...
    ... conflict with the actual sun and stars (so, ... Interface too can have some properties defined in terms of third types ... not the language or its target. ... If you ignore overflow exceptions, then necessary, the semantics becomes ...
    (comp.object)
  • Re: Code Comprehension
    ... Given a language like C, where the actual semantics differ quite ... you because of your level of familiarity. ... producing correct code and other sets of semantics that don't. ...
    (comp.programming)
  • Re: what follows from denying an axiom
    ... Chris Menzel is the first person I have ever heard say "second-order ... language purely syntactically. ... Formal system has no semantics. ... to the resultant perception-phenomenon known as relativity, ...
    (sci.logic)
  • Re: what follows from denying an axiom
    ... language purely syntactically. ... Formal system has no semantics. ... to the resultant perception-phenomenon known as relativity, ... Provability is thus relative to a proof theory, ...
    (sci.logic)
  • Re: Minimal keywords needed for constructing a full CL system
    ... | I've implemented much of CL in Emacs Lisp, ... I'm particularly concerned about the "equivalent semantics" clause ... language which meets all of the following criteria: ... |> - At least one of the set of non-local control transfer primitives ...
    (comp.lang.lisp)