标题:我是新手,请各位高手指教!
只看楼主
Forever_U
Rank: 1
等 级:新手上路
帖 子:4
专家分:0
注 册:2014-4-22
结帖率:100%
已结贴  问题点数:20 回复次数:4 
我是新手,请各位高手指教!
运行时会出现以下错误,为什么呢??
'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();

}


搜索更多相关主题的帖子: private include public double 
2014-04-22 20:23
hubinyes
Rank: 7Rank: 7Rank: 7
等 级:贵宾
威 望:11
帖 子:104
专家分:557
注 册:2014-2-4
得分:20 
不知道,你用什么编译器编译的,看样子是老版本。。现在"iostream.h"都不存在了。。
2014-04-22 21:21
Forever_U
Rank: 1
等 级:新手上路
帖 子:4
专家分:0
注 册:2014-4-22
得分:0 
……

[ 本帖最后由 Forever_U 于 2014-4-23 19:16 编辑 ]
2014-04-23 19:12
Forever_U
Rank: 1
等 级:新手上路
帖 子:4
专家分:0
注 册:2014-4-22
得分:0 
回复 2 楼 hubinyes
嗯,已经改好了。不过,谢谢你哦~
2014-04-23 19:17
鸥翔鱼游
Rank: 5Rank: 5
等 级:职业侠客
帖 子:182
专家分:323
注 册:2014-4-19
得分:0 
且学且珍惜,得认学习真正消化
2014-04-24 15:03



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-430491-1-1.html




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

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