Re: FixedSizeArray

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

Would you like to post a relpy?


This post is a reply to:
Re: FixedSizeArray
Hi Peter, Why two functions when CPPUNIT_ASSERT (array.size() == 11); works? The compiler will always be able to determine the object type and will know how to call the function. I could be (more...)

Follow-ups:
Re: FixedSizeArray
Hi Peter, ok, I've left only the static function with a note of it's other possible usage. I've also added more operators (,>=,[]) and updated docs/tests. I can't think of anything (more...)