-
Interface
-
The public part of a class
- Member function - obvious
- Non-member function
- Member types
- Member fields
- Template parameters
- Specializations
-
Example:
std::vectoron cppreference.com - The private part (implementation) is unknown
-
The public part of a class
- Object Oriented Design (OOD)
Make interfaces easy to use correctly and hard to use incorrectly
-- Scott Meyers, Effective C++
// A date class which is easy to use but also easy to use wrong.
class Date {
public:
Date(int month, int day, int year);
...
};
// Both are ok, but some european programmer may use it wrong,
// because european time format is dd/mm/yyyy instead of mm/dd/yyyy.
Date d(3, 4, 2000);
Date d(4, 3, 2000);