码迷,mamicode.com
首页 > 其他好文 > 详细

this指针

时间:2019-04-06 12:19:03      阅读:93      评论:0      收藏:0      [点我收藏+]

标签:使用   不能   code   静态   turn   ice   set   oid   ++   

1.C++程序到C程序的翻译

class Test
{
public:
    int price;
    void setPrice(int p);
};

Test::setPrice(int p)
{
    price=p;
}
struct Test
{
    int price;
};

void setPrice(struct Test* this,int p)
{
    this->price=p;
}

2.其作用就是指向成员函数所作用的对象

3.特殊用法:return *this;返回当前操作的对象

4.静态成员函数中不能使用this指针

this指针

标签:使用   不能   code   静态   turn   ice   set   oid   ++   

原文地址:https://www.cnblogs.com/-Asurada-/p/10661313.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!