为了账号安全,请及时绑定邮箱和手机立即绑定

vc++编译错误 error C2572:请问慕友们该怎么解决?

vc++编译错误 error C2572:请问慕友们该怎么解决?

C++
千万里不及你 2022-11-19 17:13:45
#include<iostream>using namespace std;class clock{public:void settime(int newh=0,int newm=0,int news=0);void showtime();private:int hour,minute,second;};void clock::settime(int newh=0,int newm=0,int news=0){hour=newh;minute=newm;second=news;}inline void clock::showtime(){cout<<hour<<":"<<minute<<":"<<second<<endl;}int main(){clock m;cout<<"first time set and output"<<endl;m.settime();m.showtime();cout<<"second time set and output"<<endl;m.settime(8,32,41);m.showtime();return 0;}
查看完整描述

2 回答

?
catspeake

TA贡献1111条经验 获得超0个赞

void clock::settime(int newh=0,int newm=0,int news=0)
{hour=newh;minute=newm;second=news;}
==>
void clock::settime(int newh,int newm,int news)
{hour=newh;minute=newm;second=news;}

查看完整回答
反对 回复 2022-11-24
?
互换的青春

TA贡献1797条经验 获得超6个赞

重复定义的问题
将Line12改为:void clock::settime(int newh,int newm,int news)就可以了

查看完整回答
反对 回复 2022-11-24
  • 2 回答
  • 0 关注
  • 76 浏览

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信