Nas*_*Ohi 0 c++ reference class
据我所知,this是一个指针,*this是一个参考.所以,如果我有一个类Sample和一个方法,如:
Sample operator++(){
int i;
for(i=0;i<this->length;i++){
this->array[i]+=1;
}
return *this;
}
Run Code Online (Sandbox Code Playgroud)
或者另一种方法.
Sample &operator++(){
int i;
for(i=0;i<this->length;i++){
this->array[i]+=1;
}
return *this;
}
Run Code Online (Sandbox Code Playgroud)
在这两者之间,这将是正确的方法吗?
| 归档时间: |
|
| 查看次数: |
52 次 |
| 最近记录: |