帮我?请使用c ++程序

时间:2011-04-17 14:20:09

标签: c++

我在Microsoft visual c ++ 6.0中工作,我不明白为什么会出现下一个错误

d:\program files\microsoft visual studio\vc98\include\iostream(16) : error C2653: 'ios_base' : is not a class or namespace name
d:\program files\microsoft visual studio\vc98\include\iostream(16) : error C2144: syntax error : missing ';' before type 'int'
d:\program files\microsoft visual studio\vc98\include\iostream(16) : error C2501: '_STD_BEGIN' : missing storage-class or type specifiers
d:\program files\microsoft visual studio\vc98\include\iostream(16) : fatal error C1004: unexpected end of file found
Error executing cl.exe.

来源:

#include stdio.h
#include conio.h
#include iostream.h
#include stdlib.h 
#include string

using std::string;
#define MAX_SIZE 32000

class Pets
{
public:
    Pets(const string &,const string &,const string &,const string &,int=0);

    void setAge (const string &); 
    string getAge() const;

    void setStatus (const string &); 
    string getStatus() const; 
    void setColour (const string &); 
    string getColour() const; 

    void setKind (const string &); 
    string getKind() const; 
    void setCost (int); 
    int getCost() const; 

    virtual void print() const; 
    virtual ~Pets()=0;

private:
    string age;
    string status;
    string colour;
    string kind;
    int cost;

};


Pets::Pets(const string &vozr,const string &state, const string &cvet,
           const string & vid, int price)
           :age(vozr),status(state),colour(cvet),kind(vid)
{
    setCost(price);
}


void Pets::setAge(const string &vozr)
{
    age=vozr;
}


string Pets::getAge() const
{
    return age;
}


void Pets::setStatus(const string &state)
{
    status=state;
}


string Pets::getStatus() const
{
    return status;
}


void Pets::setColour(const string &cvet)
{
    colour=cvet;
}

string Pets::getColour() const
{
    return colour;
}

void Pets::setKind(const string &vid)
{
    kind=vid;
}

string Pets::getKind() const
{
    return kind;
}

void Pets::setCost(int price)
{
    cost=(price>0 && price<MAX_SIZE)? price : 0;
}

int Pets::getCost() const
{
    return cost;
}

void Pets::print() const
{
    cout<<getAge()<<' '<<getStatus()<<' '<<getColour()<<' '<<getKind()<<' '<<getCost()<<endl;

}

class Cats:public Pets 
{


};

class Dogs:public Pets  //êëàññ ñîáàêè
{

};


void welcome() 
{
    cout<<"==============================================================================="<<endl;
    cout<<"||                                                                           ||"<<endl;
    cout<<"||                       *******Pet Kennel*******                            ||"<<endl;
    cout<<"||                                                                           ||"<<endl;
    cout<<"==============================================================================="<<endl;
    cout<<"press any key to continue...."<<endl;
}


// void menu() - ôóíêöèÿ âûâîäà ìåíþ íà ýêðàí
void menu() 
{   
    cout<<"||                              M E N U                                      ||"<<endl;
    cout<<"==============================================================================="<<endl;
    cout<<"|| 1 ||      Show Pet's list                                                 ||"<<endl;
    cout<<"|| 2 ||      Enter new pet                                                   ||"<<endl;
    cout<<"|| 3 ||      Edit pet                                                        ||"<<endl;
    cout<<"|| 4 ||      Sort pets                                                       ||"<<endl;
    cout<<"|| 5 ||      Delete info                                                     ||"<<endl;
    cout<<"|| 6 ||      Find status                                                     ||"<<endl;
    cout<<"|| 0 ||      Quit                                                            ||"<<endl;

    cout<<"==============================================================================="<<endl;


    cout<<"Enter number of the operation:"<<endl;
}

void main()     
{
    welcome();
    getch();
    system("cls");

    menu(); 

    getch();
}

1 个答案:

答案 0 :(得分:4)

您应该使用

#include <iostream>

#include <iostream.h>