Hi, I'm a beginner in C++ and working on my lab assignment. I get the following error, please help.
Thanks,
Skyline
error C2676: binary '+=' : 'Time' does not define this operator or a conversion to a type acceptable to the predefined operator
// Function - CalculateTotalCollectionPlayingTime()
Time MediaCollection::CalculateTotalCollectionPlayingTime()
{
if
(CurrentMCSize == 0)
{
cout <<
"***** Cannot Calculate Total Playing Time! No Media Found. *****\n"
<< endl;
}
else if
(CurrentMCSize >= 1)
{
Time time;
for
(int i; i < CurrentMCSize; i++)
{
time += Collection[i]->GetRunningTime(); // Erroring here.
}
cout << "\nTotal Collection Playing Time: " << time << " (HH:MM)" << "\n" << endl;
return 0;
}
}
// Function - GetRunningTime()
Time Media::GetRunningTime()
{
return RunningTime;
}
// Media Constructor
Media::Media()
{
Title = "Some Title";
Artist = "Some Artist";
WherePurchased = "Some where";
Cost = 0;
RunningTime.SetHours(0);
RunningTime.SetMinutes(0);
}
// Media Parameterized Constructor
Media::Media(const string &InTitle, const string &InArtist, const string
&InWherePurchased, float InCost, Time &InRunningTime)
{
Title = InTitle;
Artist = InArtist;
WherePurchased = InWherePurchased;
Cost = InCost;
RunningTime.SetHours(InRunningTime.GetHours());
RunningTime.SetMinutes(InRunningTime.GetMinutes());
}
// Function - SetMinutes(int NewMinutes)
void Time::SetMinutes(int NewMinutes)
{
if
(NewMinutes >= 0 && NewMinutes <= 59)
{
Minutes = NewMinutes;
}
else if
(NewMinutes >= 60)
{
int mm;
mm = NewMinutes % 60;
}
}