In the sample code you provided the only questionable choice of name is memset
, as it will not be obvious to users what e.memset(b)
means. In case it is not obvious what this means is thatÑ as long as the names are clear for the user this is a good thing.
Now the problem comes with the fact that names that are well known may convey more meaning than what the word actually means. For example you might write a container type like:
class MyContainer {
// ...
void add(const Element& e);
// Adds 'e' to the container
bool isEmpty() const;
// Returns true if the container is empty
void empty();
// Removes all elements from the container
};
While there is nothing inherently wrong with the choice of names, but in a container people expect empty()
to be a check that returns whether the container is empty. That would make it a poor choice for a function that does anything different as it generates confusion.
So basically it is fine to use the same identifiers, as long as the use is not in conflict and won't be confusing to other developers.