S
Schizoid Man
Hello,
Suppose I have a class called ModDate that contains three private
members - day, month, year - all defined as int.
I want to overload the += operator and add an integer value to the date
to get the new date after increments.
To do that I have the following method:
const ModDate &ModDate:
perator+=(int addDays) {
for (int i = 0; i < addDays; i++)
incrementDay();
return *this;
}
However, when I call this method in the following lines, I get compile
error C2676 binary '<<' : no operator found which takes a right-hand
operand of type 'const ModDate' (or there is no acceptable conversion)
with Visual C++.
ModDate enDate1;
enDate1.setDate(1, 1, 2001);
cout << "After increment: " << (enDate1 += 7);
I would appreciate any advice.
Thanks.
Suppose I have a class called ModDate that contains three private
members - day, month, year - all defined as int.
I want to overload the += operator and add an integer value to the date
to get the new date after increments.
To do that I have the following method:
const ModDate &ModDate:
for (int i = 0; i < addDays; i++)
incrementDay();
return *this;
}
However, when I call this method in the following lines, I get compile
error C2676 binary '<<' : no operator found which takes a right-hand
operand of type 'const ModDate' (or there is no acceptable conversion)
with Visual C++.
ModDate enDate1;
enDate1.setDate(1, 1, 2001);
cout << "After increment: " << (enDate1 += 7);
I would appreciate any advice.
Thanks.