49 - this

作者: 社交帐号直接注册 | 来源:发表于2018-01-02 21:16 被阅读0次
#include <iostream>
#include "Hannah.h"
using namespace std;

int main()
{
    Hannah ho(23);
    ho.printCrap();
    system("pause");
}

#ifndef HANNAH_H
#define HANNAH_H

class Hannah
{
public:
    Hannah(int);
    void printCrap();
private:
    int h;
};

#endif

#include <iostream>
#include "Hannah.h"
using namespace std;

Hannah::Hannah(int num):h(num)
{

}

void Hannah::printCrap()
{
    cout << "h=" << h << endl;
    cout << "this->h" << this->h << endl;
    cout << "(*this).h=" << (*this).h << endl;
}

相关文章

网友评论

      本文标题:49 - this

      本文链接:https://www.haomeiwen.com/subject/segqnxtx.html