Question: Hello, this is for programming in C++ . Below is the assignment, it deals with pointers and I am a bit lost on them so

Hello, this is for programming in C++. Below is the assignment, it deals with pointers and I am a bit lost on them so please include comments when you can. Thank you very much.
Below the assignment is the default programs associated with this assignment.  Hello, this is for programming in C++. Below is the assignment,
it deals with pointers and I am a bit lost on them
Here are the default programs as followed: clientDate.cpp, time.cpp, time.h ... (separated by dash symbols)
------------------------------------------------------------------------------------------------
//clientDate.cpp
#include
#include "date.h"
using namespace std;
int main()
{
Date date1 (9,2,2002,13,00,00,"Labor Day");
Date date2 (9,6,2002,13,00,00,"First Friday");
Date date3;
cout
cout
cout
date3 = date2;
cout
if (date1
cout
else if (date1 == date2)
cout
return 0;
}
----------------------------------------------------------------------------------------------------------------
//date.cpp
//******************************************************************
// IMPLEMENTATION FILE (date.cpp)
//******************************************************************
#include // For strcpy() and strlen()
#include
#include "date.h"
using namespace std;
//******************************************************************
Date::Date( int initMo,
int initDay,
int initYr,
const char* msgStr )
// Constructor
{
mo = initMo;
day = initDay;
yr = initYr;
msg = new char[strlen(msgStr) + 1];
strcpy(msg, msgStr);
}
//******************************************************************
Date::~Date()
{
delete [] msg;
}
//******************************************************************
Date::Date(const Date& otherDate)
{
mo = otherDate.mo;
day = otherDate.day;
yr = otherDate.yr;
msg = new char[strlen(otherDate.msg) + 1];
strcpy(msg, otherDate.msg);
otherTime.CopyFrom(otherDate.otherTime);
}
//******************************************************************
void Date::CopyFrom (const Date& otherDate)
{
mo = otherDate.mo;
day = otherDate.day;
yr = otherDate.yr;
delete [] msg; // Deallocate the
// original array
msg = new char[strlen(otherDate.msg) + 1]; // Allocate a new
// array
strcpy(msg, otherDate.msg); // Copy the chars
otherTime.CopyFrom(otherDate.otherTime);
}
//******************************************************************
void Date::Print() const
{
static char monthString[12][10] =
{
"January", "February", "March", "April", "May", "June",
"July", "August", "September", "October", "November",
"December"
};
cout
}
//******************************************************************
bool Date::LessThan (const Date& otherDate) const
{
if (yr
return true;
else if ( (yr == otherDate.yr) && (mo
return true;
else if ( (yr == otherDate.yr) && (mo == otherDate.mo)
&& (day
return true;
else if ( (yr == otherDate.yr) && (mo == otherDate.mo)
&& (day == otherDate.day) &&
otherTime.LessThan(otherDate.otherTime) )
return true;
else
return false;
}
//******************************************************************
bool Date::EqualTo(const Date& otherDate) const
{
if ( (yr == otherDate.yr) && (mo == otherDate.mo)
&& (day == otherDate.day) && otherTime.Equal(otherDate.otherTime) )
return true;
else
return false;
}
//******************************************************************
-------------------------------------------------------------------------------------------------------------------------
//date.h
//******************************************************************
// SPECIFICATION FILE (date.h)
//******************************************************************
#include "time.h"
using namespace std;
class Date
{
public:
void Print() const;
Date( int initMo = 1,
int initDay = 0,
int initYr = 0,
int initHrs = 0,
int initMins = 0,
int initSecs = 0,
const char* msgStr = "No Date");
Date( const Date& otherDate );
// Copy-constructor
~Date();
// Destructor
bool operator
bool operator == (const Date& otherDate) const;
void operator = (const Date& otherDate);
private:
int mo;
int day;
int yr;
Time otherTime;
char* msg;
friend ostream& operator
{
date.Print();
return os;
}
};
--------------------------------------------------------------------------------------------------------
Overloading Operators in the Date Class 1. Take a look at the specification file for this class and nocehow it has been set up for operator overloading. Notice also the object otherTime of the Time type that has been added to the private section of this class. So, all Date objects will now have a time object within them. This is an example of containment. This means you will need to copy over your Time class specification and implementation fron last week's lab to your current directory Type cp . ./Lab2/time. * ' to copy over these files. Notice that is a space and dot after the asterisk 2. Notice the friend function for operator

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!