this 简单用法 对比
#include <iostream>using namespace std;
/*
class T
{
public:
T(int m):m(m)
{}
void Show(){ cout << "m = " << m << endl; }
private:
int m;
};
int main()
{
T t1(4);
t1.Show();
return 0;
}
/////////////////////////////////////////////////////
class T
{
public:
T(int m):this->m(m)
{}
void Show(){ cout << "m = " << m << endl; }
private:
int m;
};
int main()
{
T t1(4);
t1.Show();
return 0;
}
///////////////////////////////////////////////////////
class T
{
public:
T(int m)
{
m = m;
}
void Show(){ cout << "m = " << m << endl; }
private:
int m;
};
int main()
{
T t1(4);
t1.Show();
return 0;
}
//////////////////////////////////////////////////////
class T
{
public:
T(int m)
{
this->m = m;
}
void Show(){ cout<< "m = " << m << endl; }
private:
int m;
};
int main()
{
T t1(4);
t1.Show();
return 0;
}
*/