| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 480 人关注过本帖
标题:请求高手帮助 改下错误
只看楼主 加入收藏
zyd909673284
Rank: 1
等 级:新手上路
帖 子:3
专家分:2
注 册:2012-6-18
结帖率:100%
收藏
已结贴  问题点数:20 回复次数:3 
请求高手帮助 改下错误
#include <iostream>
#include<string>
#include<fstream>
#include<iomanip>
using namespace std;
class pet //宠物类
{
protected:
int age,number;
char sex;
double price;
string breed;
public:
int a();
int n();
string b();
char s();
double p;
};
string pet::b()
{return breed;}
char pet::s()
{return sex;}
int pet::a()
{return age;}
int pet::n()
{return number;}
class dog:public pet //狗类
{
protected:
double price;
public:
void display1()
{cout<<"宠物狗的编号:";cin>>number;
cout<<"品种:";cin>>breed;
cout<<"性别(m/w):";cin>>sex;
cout<<"年龄:";cin>>age;
cout<<"售价:";cin>>price;
}
};
class cat:public pet //猫类
{
protected:
int number;
double price;
public:
void display2()
{cout<<"宠物猫的编号:";cin>>number;
cout<<"其品种:";cin>>breed;
cout<<"性别(m/w):";cin>>sex;
cout<<"年龄:";cin>>age;
cout<<"售价为:";cin>>price;
}
}; class mouse:public pet //鼠类
{
protected:
int number;
double price;
public:
void display3()
{cout<<"宠物鼠的编号:";cin>>number;
cout<<"其品种:";cin>>breed;
cout<<"性别(m/w):";cin>>sex;
cout<<"年龄:";cin>>age;
cout<<"售价为:";cin>>price;
}
}; class customer //顾客类
{
protected:
int conph,age;
char sex;
string name,family,buyst;
public:
int ag(),co();
string na(),fa(),bu();
char se();
};
string customer::na()
{return name;}
string customer::fa()
{return family;}
string customer::bu()
{return buyst;}
char customer::se()
{return sex;}
int customer::ag()
{return age;}
int customer::co()
{return conph;}
void cwxt()
{
cout<<"◆◆◇小小宠物店系统◇◆◆"<<endl;
cout<<"┌—————————————————┐"<<endl;
cout<<"│ 请选择您喜欢的宠物种类           │"<<endl;
cout<<"├—————┬—————┬—————┤"<<endl;
cout<<"│ 狗:a    │ 猫:b   │ 鼠:c    │"<<endl;
cout<<"├—————┼—————┼—————┤"<<endl;                
cout<<"│并按回车键│并按回车键│并按回车键│"<<endl;
cout<<"└—————┴—————┴—————┘"<<endl;
cout<<"请选择一个种类:";
}
int main()
{
int i,conph,age;
char j,sex,r;
string name,family,buyst;
cwxt();
dog d[4];
cat c[4];
mouse m[4];
customer cu[4];
cin>>j;
while(j=='a'||j=='b'||j=='c')
{switch(j)
{
case 'a':
system("CLS");
cout<<" ┌————┬——————┬——————┬——————┬——————┐"<<endl;
cout<<" │ 犬类   │ 吉娃娃(1)  │ 泰迪(2)    │ 贵宾(3)    │ 金毛列犬(4)│"<<endl;
cout<<" ├————┼——————┼——————┼——————┼——————┤"<<endl;
cout<<" │ 年龄   │ 三个月     │ 三个月     │ 四个月     │ 五个月     │"<<endl;
cout<<" ├————┼——————┼——————┼——————┼——————┤"<<endl;
cout<<" │ 性别                                          │"<<endl;
cout<<" ├————┼——————┼——————┼——————┼——————┤"<<endl;
cout<<" │        │毛色:棕    │毛色:褐    │毛色:白    │毛色:金黄  │"<<endl;
cout<<" │宠物信息│                                                │"<<endl;
cout<<" │        │体型:较小  │体型:小    │体型:标准  │体型:大    │"<<endl;
cout<<" ├————┼——————┼——————┼——————┼——————┤"<<endl;
cout<<" │ 售价   │ 550元      │ 1800元     │ 3000元     │ 700元      │"<<endl;
cout<<" └————┴——————┴——————┴——————┴——————┘"<<endl;
break;
case 'b':
system("CLS");
cout<<"┌————┬——————┬——————┬——————┬——————┐"<<endl;
cout<<"│ 猫类   │ 短毛猫 (1) │ 波斯猫(2)  │ 暹罗猫(3)  │ 卡尔特猫(4)│"<<endl;
cout<<"├————┼——————┼——————┼——————┼——————┤"<<endl;
cout<<"│ 年龄   │ 三个月        两个月   │ 三个月     │ 两个月     │"<<endl;
cout<<"├————┼——————┼——————┼——————┼——————┤"<<endl;
cout<<"│ 性别                                         │"<<endl;
cout<<"├————┼——————┼——————┼——————┼——————┤"<<endl;
cout<<"│        │毛色:黑、白│毛色:白    │毛色:棕    │毛色:蓝灰  │"<<endl;
cout<<"│宠物信息│                                                │"<<endl;
cout<<"│        │体型:魁梧  │体型:健壮  │体型:标准  │体型:稍胖  │"<<endl;
cout<<"├————┼——————┼——————┼——————┼——————┤"<<endl;
cout<<"│ 售价   │ 5500元     │ 1000元     │ 666元      │ 1500元     │"<<endl;
cout<<"└————┴——————┴——————┴——————┴——————┘"<<endl;
break;
case 'c':
system("CLS");
cout<<"┌————┬——————┬——————┬——————┬——————┐"<<endl;
cout<<"│ 鼠类   │ 天竺鼠(1)  │ 黄金鼠(2)  │ 银狐(3)    │ 通心粉鼠(4)│"<<endl;
cout<<"├————┼——————┼——————┼——————┼——————┤"<<endl;
cout<<"│ 年龄   │ 三个月     │ 三个月     │ 四个月     │ 两个月     │"<<endl;
cout<<"├————┼——————┼——————┼——————┼——————┤"<<endl;
cout<<"│ 性别                                         │"<<endl;
cout<<"├————┼——————┼——————┼——————┼——————┤"<<endl;
cout<<"│        │毛色: 棕   │毛色:金    │毛色:银白  │毛色:白、红│"<<endl;
cout<<"│宠物信息│                                                │"<<endl;
cout<<"│        │体型:小    │体型:大    │体型:标准  │体型:肥硕  │"<<endl;
cout<<"├————┼——————┼——————┼——————┼——————┤"<<endl;
cout<<"│ 售价   │ 30 元      │ 10 元          150元      200元    │"<<endl;
cout<<"└————┴——————┴——————┴——————┴——————┘"<<endl;
break;
}
if(j=='a'||j=='b'||j=='c')
cout<<"请选择您想购买的种类 ,输入编号:";
{
cin>>i;
if(i==1||i==2||i==3||i==4)
{ cout<<"您将购买"<<i<<"号宠物,请确认(y/n)!"<<endl;
cin>>r;
if(r=='y')
{
system("CLS");
cout<<" ※※请填写下面的资料※※"<<endl;
cout<<"姓名:"<<endl;
cin>>name;
cout<<"〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓"<<endl;
cout<<"性别(w/m):"<<endl;
cin>>sex;
cout<<"〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓"<<endl;
cout<<"年龄:"<<endl;
cin>>age;
cout<<"〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓"<<endl;
cout<<"购买类型:"<<endl;
cin>>buyst;
cout<<"〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓"<<endl;
cout<<"联系电话:"<<endl;
cin>>conph;
cout<<"〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓"<<endl;
cout<<"家庭住址:"<<endl;
cin>>family;
cout<<"〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓"<<endl;
cout<<"█ 〓█ ★ 填写完成,请按1 !★█ 〓 ███▄"<<endl;
int x;
cin>>x;
switch(x)
case 1:
cout<<" 为了确保您的信息丢失,请您按1进行资料备份"<<endl;
int y;
cin>>y;
switch(y)
{
case 1:
{
ofstream outfile("beifen.txt",ios::out) ;
if(! outfile)
{
cerr<<"open error!"<<endl;
exit(0);
}
cout<<"数据备份,请等待........ ";
outfile<<"顾客信息:"<<endl;
for(i=0;i<4;i++)
{
outfile<<" 姓名: "<<cu[i].na()<<" 性别: "<<cu[i].se()<<" 年龄: "<<cu[i].ag()
<<" 购买类型: "<<cu[i].bu()<<" 联系电话: "<<cu[i].co()<<" 家庭住址: "<<cu[i].fa()<<endl;
}
outfile<<"------------------------------------------------------------------"<<endl;
}
}
system("CLS");
cout<<" 恭喜您,购买成功!"<<endl;
}
else
cout<<"谢谢光临!"<<endl;
}
return 0;
}
}
}
搜索更多相关主题的帖子: pet double include public return 
2012-06-18 10:43
毕如笑
Rank: 2
等 级:论坛游民
帖 子:1
专家分:10
注 册:2012-3-7
收藏
得分:10 
回复 楼主 zyd909673284
//我也不知道为什么。就在红色加下划线的那一行后面加注释就没有错误了。

#include <iostream>
#include<string>
#include<fstream>
#include<iomanip>
using namespace std;
class pet //宠物类
{
protected:
    int age,number;
    char sex;
    double price;
    string breed;
public:
    int a();
    int n();
    string b();
    char s();
    double p;
};
string pet::b()
{return breed;}
char pet::s()
{return sex;}
int pet::a()
{return age;}
int pet::n()
{return number;}
class dog:public pet //狗类
{
protected:
    double price;
public:
    void display1()
    {cout<<"宠物狗的编号:";cin>>number;
    cout<<"品种:";cin>>breed;
    cout<<"性别(m/w):";cin>>sex;
    cout<<"年龄:";cin>>age;
    cout<<"售价:";cin>>price;
    }
};
class cat:public pet //猫类
{
protected:
    int number;
    double price;
public:
    void display2()
    {cout<<"宠物猫的编号:";cin>>number;
    cout<<"其品种:";cin>>breed;
    cout<<"性别(m/w):";cin>>sex;
    cout<<"年龄:";cin>>age;
    cout<<"售价为:";cin>>price;
    }
}; class mouse:public pet //鼠类
{
protected:
    int number;
    double price;
public:
    void display3()
    {cout<<"宠物鼠的编号:";cin>>number;
    cout<<"其品种:";cin>>breed;
    cout<<"性别(m/w):";cin>>sex;
    cout<<"年龄:";cin>>age;
    cout<<"售价为:";cin>>price;
    }
}; class customer //顾客类
{
protected:
    int conph,age;
    char sex;
    string name,family,buyst;
public:
    int ag(),co();
    string na(),fa(),bu();
    char se();
};
string customer::na()
{return name;}
string customer::fa()
{return family;}
string customer::bu()
{return buyst;}
char customer::se()
{return sex;}
int customer::ag()
{return age;}
int customer::co()
{return conph;}
void cwxt()
{
    cout<<"◆◆◇小小宠物店系统◇◆◆"<<endl;
    cout<<"┌—————————————————┐"<<endl;
    cout<<"│ 请选择您喜欢的宠物种类           │"<<endl;
    cout<<"├—————┬—————┬—————┤"<<endl;
    cout<<"│ 狗:a    │ 猫:b   │ 鼠:c    │"<<endl;
    cout<<"├—————┼—————┼—————┤"<<endl;         //
    cout<<"│并按回车键│并按回车键│并按回车键│"<<endl;
    cout<<"└—————┴—————┴—————┘"<<endl;
    cout<<"请选择一个种类:";
}
int main()
{
    int i,conph,age;
    char j,sex,r;
    string name,family,buyst;
    cwxt();
    dog d[4];
    cat c[4];
    mouse m[4];
    customer cu[4];
    cin>>j;
    while(j=='a'||j=='b'||j=='c')
    {switch(j)
    {
case 'a':
    system("CLS");
    cout<<" ┌————┬——————┬——————┬——————┬——————┐"<<endl;
    cout<<" │ 犬类   │ 吉娃娃(1)  │ 泰迪(2)    │ 贵宾(3)    │ 金毛列犬(4)│"<<endl;
    cout<<" ├————┼——————┼——————┼——————┼——————┤"<<endl;
    cout<<" │ 年龄   │ 三个月     │ 三个月     │ 四个月     │ 五个月     │"<<endl;
    cout<<" ├————┼——————┼——————┼——————┼——————┤"<<endl;
    cout<<" │ 性别                                          │"<<endl;
    cout<<" ├————┼——————┼——————┼——————┼——————┤"<<endl;
    cout<<" │        │毛色:棕    │毛色:褐    │毛色:白    │毛色:金黄  │"<<endl;
    cout<<" │宠物信息│                                                │"<<endl;
    cout<<" │        │体型:较小  │体型:小    │体型:标准  │体型:大    │"<<endl;
    cout<<" ├————┼——————┼——————┼——————┼——————┤"<<endl;
    cout<<" │ 售价   │ 550元      │ 1800元     │ 3000元     │ 700元      │"<<endl;
    cout<<" └————┴——————┴——————┴——————┴——————┘"<<endl;
    break;
case 'b':
    system("CLS");
    cout<<"┌————┬——————┬——————┬——————┬——————┐"<<endl;
    cout<<"│ 猫类   │ 短毛猫 (1) │ 波斯猫(2)  │ 暹罗猫(3)  │ 卡尔特猫(4)│"<<endl;
    cout<<"├————┼——————┼——————┼——————┼——————┤"<<endl;
    cout<<"│ 年龄   │ 三个月        两个月   │ 三个月     │ 两个月     │"<<endl;
    cout<<"├————┼——————┼——————┼——————┼——————┤"<<endl;
    cout<<"│ 性别                                         │"<<endl;
    cout<<"├————┼——————┼——————┼——————┼——————┤"<<endl;
    cout<<"│        │毛色:黑、白│毛色:白    │毛色:棕    │毛色:蓝灰  │"<<endl;
    cout<<"│宠物信息│                                                │"<<endl;
    cout<<"│        │体型:魁梧  │体型:健壮  │体型:标准  │体型:稍胖  │"<<endl;
    cout<<"├————┼——————┼——————┼——————┼——————┤"<<endl;
    cout<<"│ 售价   │ 5500元     │ 1000元     │ 666元      │ 1500元     │"<<endl;
    cout<<"└————┴——————┴——————┴——————┴——————┘"<<endl;
    break;
case 'c':
    system("CLS");
    cout<<"┌————┬——————┬——————┬——————┬——————┐"<<endl;
    cout<<"│ 鼠类   │ 天竺鼠(1)  │ 黄金鼠(2)  │ 银狐(3)    │ 通心粉鼠(4)│"<<endl;
    cout<<"├————┼——————┼——————┼——————┼——————┤"<<endl;
    cout<<"│ 年龄   │ 三个月     │ 三个月     │ 四个月     │ 两个月     │"<<endl;
    cout<<"├————┼——————┼——————┼——————┼——————┤"<<endl;
    cout<<"│ 性别                                         │"<<endl;
    cout<<"├————┼——————┼——————┼——————┼——————┤"<<endl;
    cout<<"│        │毛色: 棕   │毛色:金    │毛色:银白  │毛色:白、红│"<<endl;
    cout<<"│宠物信息│                                                │"<<endl;
    cout<<"│        │体型:小    │体型:大    │体型:标准  │体型:肥硕  │"<<endl;
    cout<<"├————┼——————┼——————┼——————┼——————┤"<<endl;
    cout<<"│ 售价   │ 30 元      │ 10 元          150元      200元    │"<<endl;
    cout<<"└————┴——————┴——————┴——————┴——————┘"<<endl;
    break;
    }
    if(j=='a'||j=='b'||j=='c')
        cout<<"请选择您想购买的种类 ,输入编号:";
    {
        cin>>i;
        if(i==1||i==2||i==3||i==4)
        { cout<<"您将购买"<<i<<"号宠物,请确认(y/n)!"<<endl;
        cin>>r;
        if(r=='y')
        {
            system("CLS");
            cout<<" ※※请填写下面的资料※※"<<endl;
            cout<<"姓名:"<<endl;
            cin>>name;
            cout<<"〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓"<<endl;
            cout<<"性别(w/m):"<<endl;
            cin>>sex;
            cout<<"〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓"<<endl;
            cout<<"年龄:"<<endl;
            cin>>age;
            cout<<"〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓"<<endl;
            cout<<"购买类型:"<<endl;
            cin>>buyst;
            cout<<"〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓"<<endl;
            cout<<"联系电话:"<<endl;
            cin>>conph;
            cout<<"〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓"<<endl;
            cout<<"家庭住址:"<<endl;
            cin>>family;
            cout<<"〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓"<<endl;
            cout<<"█ 〓█ ★ 填写完成,请按1 !★█ 〓 ███▄"<<endl;
            int x;
            cin>>x;
            switch(x)
            case 1:
                cout<<" 为了确保您的信息丢失,请您按1进行资料备份"<<endl;
                int y;
                cin>>y;
                switch(y)
                {
                case 1:
                    {
                        ofstream outfile("beifen.txt",ios::out) ;
                        if(! outfile)
                        {
                            cerr<<"open error!"<<endl;
                            exit(0);
                        }
                        cout<<"数据备份,请等待........ ";
                        outfile<<"顾客信息:"<<endl;
                        for(i=0;i<4;i++)
                        {
                            outfile<<" 姓名: "<<cu[i].na()<<" 性别: "<<cu[i].se()<<" 年龄: "<<cu[i].ag()
                                <<" 购买类型: "<<cu[i].bu()<<" 联系电话: "<<cu[i].co()<<" 家庭住址: "<<cu[i].fa()<<endl;
                        }
                        outfile<<"------------------------------------------------------------------"<<endl;
                    }
                }
                system("CLS");
                cout<<" 恭喜您,购买成功!"<<endl;
        }
        else
            cout<<"谢谢光临!"<<endl;
        }
        return 0;
    }
 }
 }
2012-06-18 13:17
zyd909673284
Rank: 1
等 级:新手上路
帖 子:3
专家分:2
注 册:2012-6-18
收藏
得分:0 
回复 2楼 毕如笑
多谢啦…………
2012-06-19 10:11
遗LOVE忘
Rank: 2
等 级:论坛游民
帖 子:9
专家分:11
注 册:2012-6-15
收藏
得分:10 
这是为什么啊????为什么加个//就没错误了呢,太神奇了吧,貌似那个//没什么作用吧
2012-06-19 10:38
快速回复:请求高手帮助 改下错误
数据加载中...
 
   



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

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