void (*pf)(int i){
};
According to C++11 I don't need a trailing ';', but Dev-C++ not only throws a Warning - but an Error and breaks compiling.
But if I'd declare
void pf(int i){
}
no warning is thrown anymore?
The two things you've shown are vastly different.
void (*pf)(int i){
};
The above defines pf as a pointer to a function taking an int and returning void, and values initializes it. The semi-colon is required. It's the same as
void (*pf)(int i) = nullptr;
In the second snippet
void pf(int i){
}
pf is a function taking an int and returning void.
I'm guessing your version of Dev-C++ doesn't support C++11's uniform initialization syntax. The following should work
void (*pf)(int i) = NULL;
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