|
|
|
|
|
by mkettn
2564 days ago
|
|
whats the advantage over declaring register_device as a functor object from an anon class?
for example: class Device;
class VFS {
public:
class {
friend Device;
void operator()(int y) {/* do stuff with y here*/}} register_device;
};
class Device {
public:
void foo(VFS fs) {
fs.register_device(1);
}
};
int main(int argc, char *argv[]) {
// fails:
// VFS().register_device(2);
// works:
Device().foo(VFS());
return 0;
}
and no need for a badge class (erm... well but an anon class).my c++ skills are a bit rusty, because most of the time python works just fine. |
|
1. Aesthetics. (This is down to personal taste of course, but I much prefer how Badge gets the job done without needing multiple lines of code at every declaration.)
2. What if I need to put the function implementation out-of-line?