-
Interfejs
-
Publiczna część klasy
- Metody (Member functions)
- Funkcje spoza klasy (Non-member functions)
- Typy wewnętrzne (Member types)
- Wewnętrzne pola (Member fields)
- Parametry szablonowe (Template parameters)
- Specjalizacje
-
Przykład:
std::vector
na cppreference.com - Część prywatna (implementacja) jest nieznana
-
Publiczna część klasy
- 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);
Jak można ulepszyć klasę Date
? Napisz w komentarzu 🙂