pure virtual fxn decl

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • A man

    pure virtual fxn decl

    Hi,
    what does the assignment " = 0 "
    signify in the pure virtual function declaration

    virtual void f() = 0 ;

    what gets the value "0" ?

    regards,
    Aman .


    --
    Posted via Mailgate.ORG Server - http://www.Mailgate.ORG
  • WW

    #2
    Re: pure virtual fxn decl

    A man wrote:[color=blue]
    > Hi,
    > what does the assignment " = 0 "
    > signify in the pure virtual function declaration
    >
    > virtual void f() = 0 ;
    >
    > what gets the value "0" ?[/color]

    Nothing. Nul. Nil. Nada. Zip.

    It means that we declare the function but will not (necessarily) give it a
    body and derived classes are better off override it unless they are abstract
    classes too.

    --
    WW aka Attila


    Comment

    • Ron Natalie

      #3
      Re: pure virtual fxn decl


      "A man " <aman@techie.co m> wrote in message news:805b00fccb 0f626f3018bde25 517fee2.26421@m ygate.mailgate. org...[color=blue]
      > Hi,
      > what does the assignment " = 0 "[/color]

      Equal signs immediately following declarations aren't assignments, it's an
      initialization.
      [color=blue]
      > signify in the pure virtual function declaration
      >
      > virtual void f() = 0 ;[/color]

      It indicates the function is pure virtual. It's just a hack to use the initialization
      sequence that wouldn't be valid anything to signify the difference between "pure
      virutal" and just "virutal." The other option would be to add a keyword like "pure"
      to the language, which people are reticent to do because adding keywords potentially
      breaks existing programs that might have used that as an identifier. It's painful
      enough dealing with new, delete, and class when moving stuff between C and C++.
      [color=blue]
      > what gets the value "0" ?[/color]

      Nothing really.



      Comment

      • Aman Angrish

        #4
        Re: pure virtual fxn decl

        Thank you !!
        regards,
        Aman.


        --
        Posted via Mailgate.ORG Server - http://www.Mailgate.ORG

        Comment

        • jeffc

          #5
          Re: pure virtual fxn decl


          "A man " <aman@techie.co m> wrote in message
          news:805b00fccb 0f626f3018bde25 517fee2.26421@m ygate.mailgate. org...[color=blue]
          > Hi,
          > what does the assignment " = 0 "
          > signify in the pure virtual function declaration
          >
          > virtual void f() = 0 ;
          >
          > what gets the value "0" ?[/color]

          Nothing. It's just a rather poor way of saying that the function is pure
          virtual.


          Comment

          Working...