-1
string foo() const = 0;

What exactly does this function declaration mean? In particular, what is the '=0' good for, since the function is not declared to be virtual?

mort
  • 12,988
  • 14
  • 52
  • 97
  • 1
    This isn't valid if `foo` isn't virtual. This line on its own doesn't prove `foo` to be nonvirtual, too. – chris Apr 05 '15 at 20:30
  • @chris: Thanks! 'foo' isn't declared virtual anywhere else; I already suspected that it doesn't make sense since I also tried to google it but nothing came up. I don't have a compiler at the ready so I thought I'd ask here – mort Apr 05 '15 at 20:33
  • 1
    http://coliru.stacked-crooked.com/ – chris Apr 05 '15 at 20:39

1 Answers1

3

The =0 is the syntax that the function is a pure virtual function. As far as i know that declaration also needs to be preceeded by the keyword virtual.

More reading about this here: What does it mean to set the declaration of a function equal to 0? How can you assign an integer to a function?

Difference between a virtual function and a pure virtual function

Community
  • 1
  • 1
Englund
  • 1,067
  • 7
  • 13