C++ 这会被视为访问器吗?(C+;+;)

C++ 这会被视为访问器吗?(C+;+;),c++,accessor,mutators,C++,Accessor,Mutators,很抱歉,格式太糟糕了,但我只是想确定以下内容是否会被视为访问器 所以我的类定义看起来像这样 class work { public: void getInput(); //Mutator void output(); //Accessor? //... 下面是函数 void work::output() { dayofweek = day + getMonthvalue(month, year) + ....; final

很抱歉,格式太糟糕了,但我只是想确定以下内容是否会被视为访问器

所以我的类定义看起来像这样

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";
  }
}
void work::output()
{
dayofweek=day+getMonthvalue(月、年)+。。。。;
最终=每周第7天;
如果(最终==0)

cout一些术语

  • 一个变量改变类中的数据
  • 访问器检索它

不,不是这样。访问者是从访问中派生出来的。

一些术语

  • 一个变量改变类中的数据
  • 访问器检索它

不,不是这样。访问者是从访问中派生出来的。

一些术语

  • 一个变量改变类中的数据
  • 访问器检索它

不,不是这样。访问者是从访问中派生出来的。

一些术语

  • 一个变量改变类中的数据
  • 访问器检索它

不,不完全是这样。访问器是从访问中派生出来的。

您显示为
输出的内容通常会作为
插入器编写:

class work { 
    // ...

    friend std::ostream &operator<<(std::ostream &os, work const &w) { 
        static char const *names[] = { 
          "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"
        };

        return os << names[getDayOfWeek(w)];
    }
};
课堂作业{
// ...

friend std::ostream&operator您显示为
输出的
通常会被编写为
插入器

class work { 
    // ...

    friend std::ostream &operator<<(std::ostream &os, work const &w) { 
        static char const *names[] = { 
          "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"
        };

        return os << names[getDayOfWeek(w)];
    }
};
课堂作业{
// ...

friend std::ostream&operator您显示为
输出的
通常会被编写为
插入器

class work { 
    // ...

    friend std::ostream &operator<<(std::ostream &os, work const &w) { 
        static char const *names[] = { 
          "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"
        };

        return os << names[getDayOfWeek(w)];
    }
};
课堂作业{
// ...

friend std::ostream&operator您显示为
输出的
通常会被编写为
插入器

class work { 
    // ...

    friend std::ostream &operator<<(std::ostream &os, work const &w) { 
        static char const *names[] = { 
          "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"
        };

        return os << names[getDayOfWeek(w)];
    }
};
课堂作业{
// ...

friend std::ostream&operator通常,访问器返回被访问的数据。同样,通常情况下,mutator更改数据成员的值。我将两者都调用neither通常,访问器返回被访问的数据。同样,mutator更改数据成员的值。我将两者都调用neither通常,访问器返回data正在被访问。通常情况下,一个mutator会改变一个数据成员的值。我会同时调用它们。通常情况下,一个accessor会返回被访问的数据。同样,一个mutator会改变一个数据成员的值。我不会同时调用它们