c++ - Unencapsulated means Unchangeable? -


i came across line in effective c++:

public means unencapsulated, , practically speaking, unencapsulated means unchangeable, classes used.yet used classes in need of encapsulation, because ones can benefit ability replace 1 implementation better one

what author mean "public means unencapsulated, , practically speaking, unencapsulated means unchangeable"?

and how unencapsulated unchangeable?

the general idea simple. if make public, can , use it. therefore, if change public, of code uses breaks. breaking people's code bad; tends lead them not wanting use code anymore, since you've forced them rewrite of stuff because wanted use different type or something.

the public interface contract between implementation of class , user of it. changing contract, particularly without advanced notice, considered rude.

if of code internal, that's fine. if it's not, if you're making library others use (whether locally or selling library), people less happy interface changes.

it isn't matter of rules of c++; it's matter of rules of interface design. since public things part of interface, must careful make public.


Comments

Popular posts from this blog

c# - SharpSVN - How to get the previous revision? -

c++ - Is it possible to compile a VST on linux? -

url - Querystring manipulation of email Address in PHP -