Re: Cstring, string ,and char
On Tue, 19 Jun 2007 17:01:42 -0400, Joseph M. Newcomer
No, consider the scenario:
You implement a class and put it up on the corporate server.
I want to implement a friend class.
I cannot modify your code.
Under those conditions, you can't add member functions, either. Granting
friendship to another class or function is equivalent to adding a member
function in terms of granting access to an entity.
The notion that there is a single "implementor" of a class or that a given source file
represents the sole view of implementation is what is at issue here.
It is safe to assume that all class definitions are deficient. If they were complete,
they would be obsolete.
I don't think that follows at all. A class that provides an adequate public
interface can be extended indefinitely by inheritance and with non-member,
non-friend functions. In fact, there's a school of thought that says
non-member, non-friend functions increase encapsulation and should be
preferred to member functions and friends. See Scott Meyers' article here:
How Non-Member Functions Improve Encapsulation
More seriously, there is a fine point between what it means to extend a class and
"implement" a class.
I think the point is sharply defined. If you can modify the class
definition, you are an implementer. If you can only use the public
interface, you are a user, or "extender", if you prefer.
Visual C++ MVP