ó chỉ là tự nhiên giao diện của họ là như vậy. C + + quy tắc im lặng về điều đó. Nó không quan trọng để ghi đè lên một chức năng cơ bản với giao diện tương tự nhưng điều này là không bắt buộc. Vì bất cứ lý do gì, rất nhiều C + + lập trình viên tin rằng giao diện phải giống nhau. | file Administrator General 20English 20Learning it2002-7-6 class SimpdPDF Merge and Split Unregistered Version - http double value public Sample double x 0 value x void set double x value x double get const return value class History enum size 8 Sample data size int idx public History idx 0 void add double void print const void average const void History add double s if idx size data idx .set s sample value default and conversion constructor modifier method selector method container class set value fixed-size array of samples index of current sample make array empty initially add a sample at the end print history print average or just data idx s void History print const cout n Measurement history endl endl for int i 0 i size i local index cout data i .get void History average const cout n Average value double sum 0 local tally for int i 0 i size i local index sum data i .get cout sum size endl int main double a 3 5 7 11 13 17 19 23 29 input data History h default constructor for int i 0 i 9 i it is protected from overflow a i add history print history print average return 0 Notice the principle of minimum visibility The container class History exhibits as little of its file ZZZZZAdministratorZGeneral 20English 721 of 1187 8Z17Z2002 2 58 01 PM file Administrator General 20English 20Learning it2002-7-6 internal structure and memory limitations to its client code as possible. Simpo PDF Merge and Split Unregistered Version - http One important limitation of container classes in Listing and is that they have to be filled to capacity before the client is allowed meaningful access to components in the container. Container methods print and average iterate over the container array until the end of the array. Another important limitation is that from the point of view of the client code all operations over components are performed as a single operation. .