如下为VC6.0中运行通过的:
你用的头文件为iostream.h,因为那时没有名词空间的定义,所以是不需要std。
出错主要为clock myclock; 没有参数传递进去,改为clock myclock(Hour,Minutes,Second);运行就通过了。
#include<iostream.h>
class clock
{
private:
int hour,minutes,second;
public:
settime();
showtime();
clock(int Hour,int Minutes,int Second);
};
clock::settime();
clock::clock(int Hour,int Minutes,int Second)
{hour=Hour;
minutes=Minutes;
second=Second;
}
clock::showtime()
{
cout<<hour<<"时"<<minutes<<"分"<<second<<"秒";}
void main()
{
int Hour, Minutes, Second;
cout<<"输出的时间为:"<<endl;
cin>>Hour>> Minutes>>Second;
clock myclock(Hour,Minutes,Second);
myclock.showtime();
}
如下为VS2005运行通过的:
#include<iostream>
using namespace std;
class clock
{
private:
int hour,minutes,second;
public:
void settime();
void showtime();
clock(int Hour,int Minutes,int Second);
};
//void clock::settime();
clock::clock(int Hour,int Minutes,int Second)
{hour=Hour;
minutes=Minutes;
second=Second;
}
void clock::showtime()
{
cout<<hour<<"时"<<minutes<<"分"<<second<<"秒";}
void main()
{
int Hour, Minutes, Second;
cout<<"输出的时间为:"<<endl;
cin>>Hour>> Minutes>>Second;
clock myclock(Hour,Minutes,Second);
myclock.showtime();
}
你用的头文件为iostream.h,因为那时没有名词空间的定义,所以是不需要std。
出错主要为clock myclock; 没有参数传递进去,改为clock myclock(Hour,Minutes,Second);运行就通过了。
#include<iostream.h>
class clock
{
private:
int hour,minutes,second;
public:
settime();
showtime();
clock(int Hour,int Minutes,int Second);
};
clock::settime();
clock::clock(int Hour,int Minutes,int Second)
{hour=Hour;
minutes=Minutes;
second=Second;
}
clock::showtime()
{
cout<<hour<<"时"<<minutes<<"分"<<second<<"秒";}
void main()
{
int Hour, Minutes, Second;
cout<<"输出的时间为:"<<endl;
cin>>Hour>> Minutes>>Second;
clock myclock(Hour,Minutes,Second);
myclock.showtime();
}
如下为VS2005运行通过的:
#include<iostream>
using namespace std;
class clock
{
private:
int hour,minutes,second;
public:
void settime();
void showtime();
clock(int Hour,int Minutes,int Second);
};
//void clock::settime();
clock::clock(int Hour,int Minutes,int Second)
{hour=Hour;
minutes=Minutes;
second=Second;
}
void clock::showtime()
{
cout<<hour<<"时"<<minutes<<"分"<<second<<"秒";}
void main()
{
int Hour, Minutes, Second;
cout<<"输出的时间为:"<<endl;
cin>>Hour>> Minutes>>Second;
clock myclock(Hour,Minutes,Second);
myclock.showtime();
}