| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 603 人关注过本帖
标题:this的使用
取消只看楼主 加入收藏
换空依晨
Rank: 1
等 级:新手上路
帖 子:44
专家分:0
注 册:2013-9-13
结帖率:30.77%
收藏
 问题点数:0 回复次数:1 
this的使用
#include"iostream"
using namespace std;
class myclass
{
public :
    myclass(int a,int b,int c);
    static void getsum();
private:
    int a,b,c;
    static int sum;

};
int myclass::sum=0;
myclass::myclass(int a,int b,int c)
{
this->a=a;
this->b=b;


this->c=c;
sum+=a+b+c;
}
void myclass ::getsum()
{
//cout<<a<<endl;//
cout<<"sum="<<sum<<endl;
}
void main()
{
myclass m(1,2,3);
m.getsum();
myclass n(4,5,6);
n.getsum();
myclass::getsum();


}
this->a=a;
this->b=b;

this->c=c;这三句是什么意思啊
搜索更多相关主题的帖子: private include public 
2014-03-06 13:12
换空依晨
Rank: 1
等 级:新手上路
帖 子:44
专家分:0
注 册:2013-9-13
收藏
得分:0 
回复 4楼 zj496884794
this 是不是每个成员函数都有的啊 怎么用的?
2014-03-06 16:01
快速回复:this的使用
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.014838 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved