strange grammar about volatile and operator overload

This is a discussion on strange grammar about volatile and operator overload within the C++ Programming forums, part of the General Programming Boards category; Hello everyone, The following code, Code: operator const Outer::Inner * volatile & (); 1. I think it means an operator ...

  1. #1
    Registered User
    Join Date
    May 2006
    Posts
    1,579

    strange grammar about volatile and operator overload

    Hello everyone,


    The following code,

    Code:
    operator const Outer::Inner * volatile & ();
    1.

    I think it means an operator &, which returns const Inner* type and takes no arguments, right?

    2.

    Adding volatile to return value means?

    (I previously only used volatile to qualify variable)


    thanks in advance,
    George

  2. #2
    Registered User
    Join Date
    Jun 2005
    Posts
    5,827
    It's an operator that converts to a reference to a volatile pointer to a const Outer::Inner.

  3. #3
    Registered User
    Join Date
    May 2006
    Posts
    1,579
    Thanks grumpy,


    To make your sentence complete, convers (from current type) to a volatile pointer to a const Outer::Inner, right?

    Quote Originally Posted by grumpy View Post
    It's an operator that converts to a reference to a volatile pointer to a const Outer::Inner.

    regards,
    George

  4. #4
    Registered User
    Join Date
    Jun 2005
    Posts
    5,827
    You left out the words "to a reference" which is implied by the ampersand at the end, but yeah.

  5. #5
    Registered User
    Join Date
    May 2006
    Posts
    1,579
    Yes, grumpy!


    It is my mistake. The complete sentence is, convers (from Outer type) to a reference of volatile pointer to a const Outer::Inner. Right?

    Quote Originally Posted by grumpy View Post
    You left out the words "to a reference" which is implied by the ampersand at the end, but yeah.

    regards,
    George

  6. #6
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    Posts
    8,892
    Well, we don't know what it converts from, because we don't have the context. It converts from whatever class it is a member of.
    All the buzzt!
    CornedBee

    "There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
    - Flon's Law

  7. #7
    Registered User
    Join Date
    May 2006
    Posts
    1,579
    Thanks CornedBee,


    Quote Originally Posted by CornedBee View Post
    Well, we don't know what it converts from, because we don't have the context. It converts from whatever class it is a member of.
    Understand. My question is answered.


    regards,
    George

Popular pages Recent additions subscribe to a feed

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21