程序的输出并解释为什么a和b显示不同的值

时间:2018-10-10 13:07:51

标签: this-pointer

#include<iostream>

using namespace std;

class Stu
{
    int a,b;

public:
    void show()
    {
        int a,b;
        a=10;
        b=15;
        cout<<"Object address is "<<this<<endl;
        cout<<"A :"<<this->a<<endl;
        cout<<"B: "<<this->b<<endl;
    }
};

int main()
{
    Stu s;
    s.show();
    return 0;
}

0 个答案:

没有答案