| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 347 人关注过本帖
标题:请大家看看哪里错了,并指出修正。谢谢
只看楼主 加入收藏
roje123
Rank: 1
等 级:新手上路
帖 子:9
专家分:0
注 册:2010-6-22
结帖率:100%
收藏
已结贴  问题点数:5 回复次数:3 
请大家看看哪里错了,并指出修正。谢谢
#include"iostream.h"

Class Time
{
     int h,m,s;
public:
     void set(int x,int y,int z);
     Time(int x=0,int y=0,int z=0);
     void Display();
};
Time::Time(int x,int y,int z)
{
  h=x;
  m=y;
  s=z;
}
void Time::set(int x,int y,int z)
{
  h=x;
  m=y;
  s=z;
}
void Time::display()
{
 cout<<h<<"时"<<m<<"分"<<s<<"秒"<<endl;
}
void main()
{
  Time h;
  h.display();
  h.set(14,24,30);
  h.display();
}

[ 本帖最后由 roje123 于 2010-6-23 18:40 编辑 ]
2010-06-23 18:32
roje123
Rank: 1
等 级:新手上路
帖 子:9
专家分:0
注 册:2010-6-22
收藏
得分:0 
出现了这样的错误提示,是什么意思?
D:\VC++6.0\MSDev98\MyProjects\3\3.cpp(4) : error C2146: syntax error : missing ';' before identifier 'Time'
D:\VC++6.0\MSDev98\MyProjects\3\3.cpp(4) : error C2501: 'Class' : missing storage-class or type specifiers
D:\VC++6.0\MSDev98\MyProjects\3\3.cpp(4) : fatal error C1004: unexpected end of file found


看不懂
2010-06-23 18:40
ilycrb
Rank: 1
等 级:新手上路
帖 子:5
专家分:4
注 册:2009-3-28
收藏
得分:4 
回复 2楼 roje123
#include "iostream.h"

class Time
{
     int h,m,s;
public:
     void set(int x,int y,int z);
     Time(int x=0,int y=0,int z=0);
     void display();
};
Time::Time(int x,int y,int z)
{
  h=x;
  m=y;
  s=z;
}
void Time::set(int x,int y,int z)
{
  h=x;
  m=y;
  s=z;
}
void Time::display()
{
cout<<h<<"时"<<m<<"分"<<s<<"秒"<<endl;
}
void main()
{
  Time h;
  h.display();
  h.set(14,24,30);
  h.display();
}
这样就可以啦
2010-06-23 19:13
暗夜冰枫
Rank: 1
等 级:新手上路
帖 子:6
专家分:1
注 册:2008-11-6
收藏
得分:1 
我也是新学的 我看了下大概是如下几个问题 如有错误请高手指正
#include"iostream.h"

Class Time//class应该用小写?
{
     int h,m,s;
public:
     void set(int x,int y,int z);
     Time(int x=0,int y=0,int z=0);
     void Display();//下面调用是小写的display()
};
Time::Time(int x,int y,int z)
{
  h=x;
  m=y;
  s=z;
}
void Time::set(int x,int y,int z)
{
  h=x;
  m=y;
  s=z;
}
void Time::display()
{
cout<<h<<"时"<<m<<"分"<<s<<"秒"<<endl;
}
void main()
{
  Time h;
  h.display();
  h.set(14,24,30);//这个分号是中文格式的
  h.display();
}
===========
如上三处修改下应该可以了
2010-06-23 23:15
快速回复:请大家看看哪里错了,并指出修正。谢谢
数据加载中...
 
   



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

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