函数重载中的C ++默认参数评估一次还是每次?

| 我对对象中的重载函数的默认值有疑问。 如果我具有以下函数签名,则默认值将仅被评估一次还是每次?
class X
{
  public:
  f(const RWDate& d=RWDate::now());
}

// when calling f() do I get the current time each time?
X z;
z.f();

// is the default value of d recaculated in the function call?
z.f();
    
已邀请:
默认参数在调用站点处被替换,因此将“ 1”转换为
z.f(RWDate::now())
因此,每次调用函数并使用默认参数时都会评估默认参数。     

要回复问题请先登录注册