abstractDataType.pptVIP

  • 3
  • 0
  • 约7.8千字
  • 约 25页
  • 2016-11-27 发布于河南
  • 举报
abstractDataType

Abstract Data Type Summary A class can be used not only to combine data but also to combine data and functions into a single (compound) object. A member variable or function may be either public or private It can be used outside of the class when it’s public It can only be used by other member functions of the same class when it’s private An object of a class can be copied by “=“, memberwise copy (for static classes) ‘const’ is part of the function definition A constructor is a member function called automatically when an object is declared Each class has to have at least one constructor Constructors can be overloaded as long as the argument lists are different What is an abstract data type? A data type consists of a collection of values together with a set of basic operations on these values A data type is an abstract data type if the programmers who use the type do not have access to the details of how the values and operations are implemented. All pre-defined types such as int, double, … are abstract data types An abstract data type is a ‘concrete’ type, only implementation is ‘abstract’ Abstract Data Type An Abstract Data Type is a class with some special restrictions. These restrictions can make programming easier. One of these restrictions is called information hiding, used as black boxes, hide the implementation details In information hiding, the user should not be allowed to access the data members directly (they should be private). An Abstract Data Type is used in Object-Oriented Programming. How to do it in C++ with classes? Make all the member variables private ? private data (implementation details) Make member functions public ? public interface Separate the public interface from implementation, If you change the implementation, you don’t need to change the other parts of the programmes. Multiplication Division Rational Review Rational number Ratio of two integers: a/b Numerator over the denominator S

文档评论(0)

1亿VIP精品文档

相关文档