语法错误
#include<iostream>using namespace std;
class Vehicle
{
public:
Vehicle(float speed=0,int total=0)
{
Vehicle::speed=speed;
Vehicle::total=total;
}
protected:
float speed;
int total;
};
class Motor
{
public:
Motor(char*motor)
{
Motor::motortype=motor;
}
char* SMT(Motor &temp);
protected:
char* motortype;
};
char* Motor::SMT(Motor &temp)
{
return temp.motortype;
}
class Car:public Vehicle
{
public:
Car(float speed,int total,int aird,char* mototype):Vehicle(speed,total),motor(motortype)
{
Car::aird=aird;
}
Motor rm(Car &temp);
protected:
int aird;
Motor motor;
};
Motor Car::rm(Car &temp)
{
return temp.motor;
}
void test101(Vehicle &temp)
{
};
void test102(Motor &temp)
{
cout<<temp.SMT(temp);
}
void test24()
{
Car a(150,4,250,"奥地利AVL V8");
test101(a);
test102(a.rm(a));
}
上述代码是一个教程上的例子,但是提示有语法问题,是在第34行,提示:“motorytpye”没有定义。
请问应该如何修改?
谢谢!