初始化列表中不能使用this指針,在構造函數體內能夠

今天在初始化列表中使用瞭如下this指針,發現有錯。因而作了如下測試。html struct h { int a; h(int x = 0) : this->a(x) { cout << this << endl; cout << this->a << endl; } }; int main() { h n; cout << &n << endl;   getchar();
相關文章
相關標籤/搜索