Why do we need classes, why can’t we just use structs?
- Classes provides more flexibility than structs. Classes can hold functions as well as data.
What are methods?
- Methods are functions defined inside of a class.
How would you define a class?
class DateClass
{
public:
int m_year;
int m_month;
int m_day;
void print()
{
std::cout << m_year;
}
};
What is an object?
- A variable of a class type is called an object.