【发布时间】:2014-12-11 02:39:29
【问题描述】:
抱歉,格式很糟糕,但我只是想确定以下内容是否会被视为访问器。
所以我的类定义看起来像这样......
class work {
public:
void getInput(); //Mutator
void output(); //Accessor?
//...
所以这里的功能..
void work::output()
{
dayofweek = day + getMonthvalue(month, year) + ....;
final = dayofweek % 7;
if(final == 0)
cout << "The day of the date is Sunday\n";
else if(final == 1)
cout << "The day of the date is Monday\n";
else if(final == 2)
cout << "The day of the date is Tuesday\n";
/*.
.
.*/
else {
cout << "The day of the day is Saturday\n";
}
}
【问题讨论】:
-
通常,访问器返回被访问的数据。
-
通常,mutator 会改变数据成员的值。
-
我两个都不叫