Hi Petr,
- I think it’s not very well known behavior (especially among less experienced C++ programmers), so one could be confused that there is only a static function and call something like PeerInfo::size() or peerInfo.toByteArray().size() instead of peerInfo.size() when needed. But maybe I’m wrong and it’s known ;).
I’d rather think that someone who does not know what a static function is would not know that it can also be called using the class name. object.foo() seems the more intuitive expression to me.
- From what I’ve read, it’s not recommended way of calling static functions (for example, one of the best C++ writers in the Czech Republic says, that it leads to less well-arranged code).
Hm, could you give an example and/or explanation? Maybe he meant certain situations involving class hierarchies? I don’t see a problem as the compiler should always be able to determine the correct function to call at compile time. I don’t know how bad that actually is, but IMO duplicating API is real bad! However, I looked at QByteArray and it has a number of non-static overloads of setNum() and a number of static overloads number() that essentially do the same thing (it seems though that Trolltech forgot write the static version of all setNum() functions).
Regards,
Peter
