



Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
An overview of c++ classes, focusing on defining new types, the date class, class declaration and member functions. It covers the concepts of public and private members, constructors, and member function implementation. The document also discusses the differences between classes and structs.
Typology: Study notes
1 / 6
This page cannot be seen from the preview
Don't miss anything!




We have been using C++ classes (from the standard library) already this semester, so by studying how the Date example we are just repeating what we have already done, but this time with a class we have defined. We will illustrate with the file date_main.cpp:
tomorrow.increment();
The code for the Date example is in three files:
Member functions that do not change the member variables should be declared const
bool Date::isEqual(const Date &date2) const
Add a member function to the Date class to add a given number of days to the Date object. The number should be the only argument and it should be an unsigned int. Should this function be const?
Rule for the duration of CS II: We will not allow the use of struct, and no member variable can be made public. This will be enforced with various levels of grading penalties.