标题:有关类类型的问题,很是奇怪啊
取消只看楼主
张海锋
Rank: 2
等 级:论坛游民
帖 子:52
专家分:37
注 册:2012-12-8
结帖率:55.56%
已结贴  问题点数:20 回复次数:0 
有关类类型的问题,很是奇怪啊
#include<iostream.h>
class clock{
public:
clock(int h,int m,int s)
{
H=h;
M=m;
S=s;
cout<<"constructor"<<H<<":"<<M<<":"<<S<<endl;
}
~clock()
{
cout<<"destructor"<<H<<":"<<M<<":"<<S<<endl;
}
clock(clock &p)
{
H=p.H;
M=p.M;
H=p.S;
}
void showtime()
{
cout<<H<<":"<<M<<":"<<S<<endl;
}
};
clock fun(clock c)
{
return c;
}
int main()
{
clock c1(8,0,0);
clock c2(9,0,0);
clock c3(c2);
fun(c2);
clock c4;这里的定义的对象c4会报错额,但是如果写成clock c4=c2编译器又不会报错啊
c4=c2;
return 0;
}
搜索更多相关主题的帖子: clock include public return 
2013-03-05 20:40



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-399836-1-1.html




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

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