| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 767 人关注过本帖
标题:这个人员类有什么问题 怎么解决
只看楼主 加入收藏
不会游的鱼
Rank: 1
等 级:新手上路
帖 子:9
专家分:0
注 册:2008-9-22
收藏
 问题点数:0 回复次数:5 
这个人员类有什么问题 怎么解决
这个人员类有什么问题,该怎么解决
#include<iostream>
using namespace std;
class Birthday
{
private:
        int Year;
        int Month;
        int Day;

public:
        Birthday(){};
        Birthday(int y,int m,int d)
  {Year=y;Month=m;Day=d;}
  void Set(int y,int m,int d){Year=y;Month=m;Day=d;}
  void Show(){Cout<<Year<<"-"<<Month<<"-"<<"Day;
  };
 
Birthday::Birthday(Birthday &b)
 {Year=b.Year;
Month=b.Month;
Day=b.Day;
}

class Person
{
private:
       char number;
    char sex;
    charID[19];
    int birthday;
public:
 Person(){};
 Person::Person(int n,int y,int m,int d,char s='m',char id[19]):birthday(y,m,d)
 {number=n;
 sex=m;
 strpcy(ID,id);
 }
 ~Person(){};


 
 
   
 

 Person(Person &p)
 {
number=p.number;
 sex=p.sex;
 birthday=p.birthday;
 strpcy(ID,p.id);
 }
 void input();
 void output();
};
void Person::input()
{cout<<"录入数据"<<endl;
cout<<"编号"<<endl;
cin>>number;
cout<<"性别"<<endl;
cin>>(m||f);
cout<<"生日"<<endl;
cout<<"身份证号"<<endl;
cin>>ID;
ID[18]='0';
}
void Person::output();
cout<<"编号"<<number;
cout<<"性别"<<sex;
cout<<"生日"<<birthday;
cout<<"身份证号"<<ID<<endl;
}
void main()
{ Person p1
p1.input();
p1.output();
return(0);

}
搜索更多相关主题的帖子: 这个人员类有什么问题 怎么解决 person() 
2008-11-20 11:51
sunkaidong
Rank: 4
来 自:南京师范大学
等 级:贵宾
威 望:12
帖 子:4496
专家分:141
注 册:2006-12-28
收藏
得分:0 
你要好好看看书了

学习需要安静。。海盗要重新来过。。
2008-11-20 11:52
shmilytong
Rank: 1
等 级:新手上路
帖 子:38
专家分:0
注 册:2008-10-31
收藏
得分:0 
赞成楼上的观点,改到一半实在改不下去了……
2008-11-20 14:17
asd6791868
Rank: 1
来 自:逆流
等 级:新手上路
帖 子:362
专家分:7
注 册:2008-7-27
收藏
得分:0 
public:
        Birthday(){};
        Birthday(int y,int m,int d)
  {Year=y;Month=m;Day=d;}
  void Set(int y,int m,int d){Year=y;Month=m;Day=d;}
  void Show(){Cout<<Year<<"-"<<Month<<"-"<<"Day;
  };

Birthday::Birthday(Birthday &b)
{Year=b.Year;
Month=b.Month;
Day=b.Day;
}

单是这里就够乱的了。。。。。
有些更能重复了

─條路 :  ┈片天  ┈個人  ─瞬間:
2008-11-20 20:47
hitcolder
Rank: 1
等 级:新手上路
威 望:1
帖 子:124
专家分:0
注 册:2008-10-28
收藏
得分:0 
我也是新手,不过确实有好多问题啊,尝试着改了下,互相学习吧:( 问题可真的不少,建议楼主先编点简单的,还有可以考虑好好看看构造函数是怎么用的,还有构造函数的重载问题。)

#include<iostream>
using namespace std;

// define class of Birthday
class Birthday
{
        int Year;   //C++默认私有变量,不需要private
        int Month;
        int Day;

public:
        //Birthday(Birthday &b);//函数声明不需要加{},还有声明的形式要跟下面定义的相一致
        Birthday(int y,int m,int d)
        {Year=y;
        Month=m;
        Day=d;}

  void Set(int y,int m,int d)
  {Year=y;
  Month=m;
  Day=d;}

  void Show()
  {
   cout<<Year<<" . "<<Month<<" . "<<Day;
  }
};

//Birthday::Birthday(Birthday &b)   
//{Year=b.Year;
//Month=b.Month;
//Day=b.Day;   
//}

//define class of Person
class Person
{
    int number;
    char sex;
    long int ID;
    int birthday;
public:
    Person(Person &p)
    {
      number=p.number;
      sex=p.sex;
      birthday=p.birthday;
      ID=p.ID;
    }

Person(int n,char m,long int id,long int bir)
{number=n;
sex=m;
ID=id;
birthday=bir;
}

void in_put()
{
cout<<"录入数据"<<endl;
cout<<"编号:";
cin>>number;
cout<<endl;
cout<<"性别:";
cin>>sex;
cout<<endl;
cout<<"生日:";
cin>>birthday;
cout<<endl;
cout<<"身份证号:";
cin>>ID;
cout<<endl;
}
void out_put()
{
cout<<"编号"<<number<<endl;
cout<<"性别"<<sex<<endl;
cout<<"生日"<<birthday<<endl;
cout<<"身份证号"<<ID<<endl<<endl;
}
};

//the main function
int  main()
{
    Person p(12,'f',123,56);                     
    Birthday birth(1984,10,30);
cout<<"the birthday is:  ";
birth.Show();
cout<<endl;

p.out_put();

return 0;
}

不要在你的智慧中夹杂傲慢,也不要使你们的谦卑缺乏智慧的成分。
2008-11-20 20:55
不会游的鱼
Rank: 1
等 级:新手上路
帖 子:9
专家分:0
注 册:2008-9-22
收藏
得分:0 
谢谢啦!!!
2008-11-21 19:40
快速回复:这个人员类有什么问题 怎么解决
数据加载中...
 
   



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

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