帮助我?请使用c+上的程序+; 我在微软Visual C++ 6中工作,我不明白为什么下一个错误会出现 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.
资料来源:帮助我?请使用c+上的程序+; 我在微软Visual C++ 6中工作,我不明白为什么下一个错误会出现 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.,c++,C++,资料来源: #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
#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();
}
#包括stdio.h
#包括conio.h
#包括iostream.h
#包括stdlib.h
#包含字符串
使用std::string;
#定义最大尺寸32000
班级宠物
{
公众:
Pets(常量字符串&,常量字符串&,常量字符串&,常量字符串&,int=0);
无效设置(常量字符串&);
字符串getAge()常量;
无效设置状态(常量字符串&);
字符串getStatus()常量;
void setcolor(常量字符串&);
字符串getcolor()常量;
void setKind(常量字符串&);
字符串getKind()常量;
无效成本(int);
int getCost()常量;
虚空打印()常量;
虚拟~Pets()=0;
私人:
弦年龄;
字符串状态;
弦色;
弦类;
国际成本;
};
Pets::Pets(常量字符串和vozr、常量字符串和状态、常量字符串和cvet、,
常量字符串和视频,整数价格)
:年龄(vozr)、状态(状态)、颜色(cvet)、种类(vid)
{
设定成本(价格);
}
无效Pets::设置(常量字符串和vozr)
{
年龄=vozr;
}
字符串Pets::getAge()常量
{
回归年龄;
}
void Pets::setStatus(常量字符串和状态)
{
状态=状态;
}
字符串Pets::getStatus()常量
{
返回状态;
}
无效宠物::设置颜色(常量字符串和cvet)
{
颜色=cvet;
}
字符串:getColor()常量
{
返色;
}
void Pets::setKind(常量字符串和vid)
{
种类=视频;
}
字符串Pets::getKind()常量
{
回报类;
}
无效宠物::设置成本(整数价格)
{
成本=(价格>0&&price您应该使用
#include <iostream>
#包括
不是
#包括
等等。有足够权限的人可以将此移到SO并修复格式吗?请不要使用粗体字母,这不是提出此问题的正确位置!如果您想知道为什么会被否决,原因如下:1:这应该在stackoverflow上进行,而不是在这里。2:您没有尽最大努力正确地解决此问题整理你的问题。在include指令中,粗体可能与#一起出现。这应该被迁移,以便在stdio.h等和其他include需求周围放上尖括号。此外,在附近添加使用std::cout
使用std::string
,或者使用std::cin
替换getch
我不确定这是他的第一个C++程序。我很高兴他会在一个地狱里。ride@RYUZAKI哈哈。当C/C++发明时,他们在想什么?(简单易用绝对不是一个考虑因素!)@丹尼。不,这些语言在今天不容易使用。但是这些语言是60年代发明的。当时它们当然是最容易使用的语言。但我仍然喜欢它们。当我用C/C++编写代码时,我感到很自在。向这两种语言致敬。它们发明几十年后,它们今天仍然是相关的。也是大多数规定性语言借用C语言的语法。
#include <iostream.h>