I'd like to know what this expression means??
typedef bool (*compareShapes)(const Shape* s1, const Shape* s2);
The Shape
is a class.
You should be using using-statements. It make the very same declaration easier to read:
using compareShapes = bool(*)(const Shape*, const Shape*);
See it now? the type is after the equal sign. It's a pointer to function type.
One could declare it like this too:
// function pointer type --v----------------------------------------------------v
using compareShapes = std::add_pointer_t< bool(const Shape*, const Shape*) >;
// function signature -----^------------------------------^
The function signature is composed like this:
<return-type>( <arguments...> )
When you add the pointer in it, it looks like this:
<return-type>(*)( <arguments...> )
And if you add the pointer name or type name here, add it after the star:
<return-type>(*typeOrPointerName)( <arguments...> )
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With