pure virtual fxn decl

A

A man

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

virtual void f() = 0 ;

what gets the value "0" ?

regards,
Aman .
 
W

WW

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

virtual void f() = 0 ;

what gets the value "0" ?

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.
 
R

Ron Natalie

A man said:
Hi,
what does the assignment " = 0 "

Equal signs immediately following declarations aren't assignments, it's an
initialization.
signify in the pure virtual function declaration

virtual void f() = 0 ;

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++.
what gets the value "0" ?

Nothing really.
 
J

jeffc

A man said:
Hi,
what does the assignment " = 0 "
signify in the pure virtual function declaration

virtual void f() = 0 ;

what gets the value "0" ?

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

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top