Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

what does value assignment to a function do? On a virtual function

Tags:

c++

I need to understand these statements:

virtual string FOOy() = 0;
virtual string FOOx( bool FOOBAR ) = 0;

I am not sure if the function being virtual has anything to do with it...

like image 772
nulltorpedo Avatar asked Dec 06 '22 16:12

nulltorpedo


1 Answers

Although your testcase is woefully incomplete, from the presence of the keyword virtual it looks like this is inside a class definition.

In such a context, = 0 is not an assignment at all, but a piece of confusing syntax that marks the virtual member function as being "pure". A pure virtual member function may have an implementation (defined elsewhere), but one is optional and the function's very existence prohibits the class from being instantiated.

That is, a class with pure virtual member functions may be called "abstract".

Your peer-reviewed C++ book covers the topic in much greater detail.

like image 75
Lightness Races in Orbit Avatar answered May 17 '23 13:05

Lightness Races in Orbit