编了个C++程序出错,编译器指出行数有问题(为226行),帮忙看看哪错了
file1.hclassgolf{private:charfullname[40];inthandicap;public:golf();golf(constchar*na...
file1.h
class golf
{
private:
char fullname[40];
int handicap;
public:
golf();
golf(const char*name,int hc);
void setgolf();
void hhandicap(int hc);
void show();
}
file2.cpp
#include"file1.h"
#include<cstring>
#include<iostream>
using namespace std;
golf::golf()
{
strcpy(fullname,"no name");
handicap=0;
}
golf::golf(const char*name,int hc)
{
strncpy(fullname,name,40);
fullname[39]='\0';
handicap=hc;
}
void golf::setgolf()
{
cout<<"Enter the fullname: ";
char dong[40];
cin.getline(dong,40);
strcpy(fullname,dong);
cout<<"Enter the hanicap: ";
int xi;
cin>>xi;
handicap=xi;
}
void golf::hhandicap(int hc)
{
handicap=hc;
}
void golf::show()
{
cout<<"fullname: "<<fullname<<endl;
cout<<"handicap: "<<handicap<<endl;
}
file3.cpp
#include"file1.h"
#include<iostream>
using namespace std;
int main()
{
golf one;
golf two("cong rui",60);
one.show();
two.show();
one.setgolf();
one.hhandicap(0);
one.show();
two.show();
return 0;
} 展开
class golf
{
private:
char fullname[40];
int handicap;
public:
golf();
golf(const char*name,int hc);
void setgolf();
void hhandicap(int hc);
void show();
}
file2.cpp
#include"file1.h"
#include<cstring>
#include<iostream>
using namespace std;
golf::golf()
{
strcpy(fullname,"no name");
handicap=0;
}
golf::golf(const char*name,int hc)
{
strncpy(fullname,name,40);
fullname[39]='\0';
handicap=hc;
}
void golf::setgolf()
{
cout<<"Enter the fullname: ";
char dong[40];
cin.getline(dong,40);
strcpy(fullname,dong);
cout<<"Enter the hanicap: ";
int xi;
cin>>xi;
handicap=xi;
}
void golf::hhandicap(int hc)
{
handicap=hc;
}
void golf::show()
{
cout<<"fullname: "<<fullname<<endl;
cout<<"handicap: "<<handicap<<endl;
}
file3.cpp
#include"file1.h"
#include<iostream>
using namespace std;
int main()
{
golf one;
golf two("cong rui",60);
one.show();
two.show();
one.setgolf();
one.hhandicap(0);
one.show();
two.show();
return 0;
} 展开
4个回答
展开全部
编译器指出的问题,你如果认真分析,一定能找出来的
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
golf类的声明最后}后面要加个分号
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
类的声明最后要加分号,否则会出现一些很奇怪的错误.
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
麻烦把226行指出来,还有出了什么错指出来
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询