这个指针在构造函数中

use*_*792 0 c++ class this

下面的代码是类的构造函数,这个类有一个成员

int               ** busyhours      ;
Run Code Online (Sandbox Code Playgroud)

构造函数

Instructor::Instructor ( int id , string name )
{
  this->id   = id   ;
  this->name = name ;

  // initialize busyhours
  this->busyhours = new int * [DAYS_WORKING] ;
  for ( int i = 0 ; i < DAYS_WORKING ; i++ )
  {
       busyhours[i] = new int[HOURS_PER_DAY] ;
       for ( int j = 0 ; j < HOURS_PER_DAY ; j++ )
        busyhours[i][j] = 0 ;
  }
}
Run Code Online (Sandbox Code Playgroud)

busyhour成员首先与此指针一起使用但是在没有此指针的情况下使用它.我不明白为什么.谢谢你的回答.

rab*_*bit 5

this 是隐式的,只有在参数与成员变量同名时才需要