关于 C++ 中 this 指针的使用~
#include<iostream>#include<string>
using namespace std;
class student
{
private:
int num;
string name;
float grade;
public:
student();
void put(student *this);
};
student::student()
{
num=0;
name="none";
grade=0;
}
void student::put(student *this)
{
cout<<this->num<<endl;
cout<<this->name<<endl;
cout<<this->grade<<endl;
}
void main()
{
student stu;
stu.put(&stu);
}
本想用此程序来验证一下this指针的用法的,却无论如何都无法运行~请问哪儿出了错?