| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 367 人关注过本帖
标题:一个错误 求高手指教
只看楼主 加入收藏
糊涂无罪
Rank: 3Rank: 3
等 级:论坛游侠
帖 子:37
专家分:161
注 册:2012-5-28
结帖率:77.78%
收藏
已结贴  问题点数:5 回复次数:1 
一个错误 求高手指教
#include <iostream>
#include <string>
using namespace std;

class Date
{
private:
    int year;
    int month;
    int day;
public:
    Date(){}  
    Date(int y,int m,int d)
    {
        year=y;
        month=m;
        day=d;
    }
    void set()
    {
        cin>>year>>month>>day;
    }
    void display()
    {
        cout<<year<<"年"<<month<<"月"<<day<<"日";
    }
};

class people
{
private:
    char num[7];
    char sex[3];
    Date birthday;
    char ID[16];
public:
    people(){}
    people(char n[7],int y,int m,int d,char id[16],char s[3]):birthday(y,m,d)
    {
        strcpy(num,n);  
        strcpy(sex,s);
        strcpy(ID,id);
    }
    people(people& p)
    {
        strcpy(num,p.num);
        strcpy(sex,p.sex);
        
        birthday=p.birthday;
        strcpy(ID,p.ID);
    }
    void input()
    {
        cout<<"录入数据:"<<endl;
        cout<<"编号:";
        num[7]='\0';
        cout<<endl;
        cin>>num;
        cout<<"性别(m/f):";
        cin>>sex;
        sex[3]='\0';
        cout<<endl;
        cout<<"生日:";
        birthday.set();
        cout<<"身份证号:";
        cin>>ID;
        ID[16]='\0';
        cout<<endl;
    }
    void output()
    {
        cout<<"编号:"<<num<<endl;
        cout<<"性别:"<<sex<<endl;
        cout<<"生日:";
        birthday.display();
        cout<<endl;
        cout<<"身份证号:"<<ID<<endl;
    }
    ~people()
    {
        cout<<" "<<num<<"号人员已经录入"<<endl;
    }
};

class student:virtual public people{
private :
    char classNO[7];
public:
    student(char n[7],int y,int m,int d,char id[16],char s[3],char no[7]):
      people( n[7], y, m, d, id[16], s[3]) {
          strcpy(classNO,no);
          cout<<"the constructing of student is called"<<endl;}
};
搜索更多相关主题的帖子: void private display include public 
2012-05-31 21:40
hellovfp
Rank: 16Rank: 16Rank: 16Rank: 16
等 级:禁止访问
威 望:30
帖 子:2976
专家分:7697
注 册:2009-7-21
收藏
得分:5 
#include <cstring>

class student:virtual public people
{
private :
    char classNO[7];
public:
    student(char n[7],int y,int m,int d,char id[16],char s[3],char no[7]):
        people( n, y, m, d, id, s)
    {
        strcpy(classNO,no);
        cout<<"the constructing of student is called"<<endl;
    }
};

我们都在路上。。。。。
2012-06-03 11:38
快速回复:一个错误 求高手指教
数据加载中...
 
   



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

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