May 28, 2013 at 7:05pm UTC
directory.cpp:104: error: call of overloaded ‘VVisit(bool&, rc_t (*&)(const slib::fDirectory*, uint32_t, const char*, void*), const char*&, void*&, __va_list_tag [1])’ is ambiguous
rc_t fDirectory::Visit(bool recurse, rc_t (*f)(const fDirectory *dir, uint32_t type, const char *name, void *data), void *data, const char *path, ...) const
{
va_list args;
va_start(args, path);
rc_t rc = VVisit(recurse, f, path, data, args); //line 104
va_end(args);
return rc;
}
rc_t VVisit(bool recurse, rc_t (*f)(const fDirectory *dir, uint32_t type, const char *name, void *data), void *data, const char *path, va_list args) const;
rc_t VVisit(bool recurse, rc_t (*f)(fDirectory *dir, uint32_t type, const char *name, void *data), void *data, const char *path, va_list args);
There are two function with same signature, but one is constant function, the other is not, how can I call the const function with no errors?
May 29, 2013 at 12:47am UTC
try putting one of the functions in its own namespace
May 29, 2013 at 8:16am UTC
Having two methods with the same name, one of which modifies the state of the class and one of which doesn't, seems inherently unintuitive to me. The name of the method should make it clear what it is a method does. If those methods are doing conceptually different things, then that should be reflected in their names.