Reputation: 1211
This is a niche question, but I'm struggling to find a sufficient answer.
Struct members can be const, but can a function pointer/reference member be declared const? Based off my reading of C++17 section 9.3, I don't think so:
struct Ex {
const int i;
void (*pfn)(int i); // 1. can pfn be a const member?
void (&rfn)(int i); // 2. can rfn be a const member?
};
Upvotes: 3
Views: 88
Reputation: 117812
struct Ex {
const int i;
void (*const pfn)(int i); // 1. can pfn be a const member?
void (&rfn)(int i); // 2. can rfn be a const member?
};
Upvotes: 5