我是新手,请各位高手指教!
运行时会出现以下错误,为什么呢??'std' : does not exist or is not a namespace//不存在或不是一个名称空
#include"iostream.h"
#include"string.h"
using namespace std;
//定义车类
class Vehicle
{
private:
double Maxspeed;
double Weight;
public:
void Run();
void Stop();
Vehicle(double Maxsp,double Weigh)
{
Maxspeed=Maxsp;
Weight=Weigh;
}
};
void Vehicle::Run()
{
cout<<"车子行驶的最大速度为:"<<Maxspeed<<endl;
cout<<"车子的重量为(单位:吨):"<<Weight<<endl;
}
//定义自行车类(虚拟)继承Vehicle
class Bicycle:virtual public Vehicle
{
private:
char Color[10];
public:
void print();
Bicycle(double Maxsp,double Weigh,char *Colo);
};
Bicycle::Bicycle(double Maxsp,double Weigh,char *Colo):Vehicle(Maxsp,Weigh)
{
strcpy(Color,Colo);
}
void Bicycle::print()
{
cout<<"自行车"<<endl;
cout<<"自行车的颜色是:"<<Color<<endl;
}
//定义Car类(虚拟)继承Vehicle
class Car:virtual public Vehicle
{
private:
char Type[20];
public:
void prin();
Car(double Maxsp,double Weigh,char *Typ):Vehicle (Maxsp,Weigh)
{
strcpy(Type,Typ);
}
};
void Car::prin()
{
cout<<"汽车"<<endl;
cout<<"汽车的型号---"<<Type<<endl;
}
//定义Motor类公共继承Bicyle类和Car类
class Motor:public Bicycle,public Car
{
public:
Motor(double Maxsp,double Weigh,char *Colo,char *Typ):Bicyle(Colo),Car(Typ),Vehicle(Maxsp,Weigh)
{
//??没有适当的默认构造函数可用??
}
void display();
};
void Motor::display()
{
cout<<"摩托车"<<endl;
}
void main()
{
Motor t(101,1,"红色","保时捷");
t.display();
t.Run();
t.print();
t.prin();
}