#include <iostream>
using namespace std;
class Vehicle
{
public:
Vehicle() {};
virtual ~Vehicle() {};
virtual void Move() = 0;
virtual void Haul() = 0;
};
class Car : public Vehicle
{
public:
Car() {};
virtual ~Car() {};
virtual void Move(int m) { cDist = m;
cout << "Vehicle moves " << cDist << " miles/hour\n"; }
virtual void Haul() { cout << "Car's Hauling!\n"; }
private:
int cDist;
};
class Bus : public Car
{
public:
Bus() {};
virtual ~Bus() {};
void Move(int m) { Move(m); }
void Haul() { "Bus is Hauling!\n"; }
};
int main()
{
Vehicle* ptCar = new Car;
Vehicle* ptBus = new Bus;
ptCar->Move(1000);
system("pause");
return 0;
}
ребята, почему этот код выдаёт мне ошибки при попытке создать экземпляр объекта Car и Bus в main. Я не собирался создавать абстрактный класс Car and Bus, только Vehicle ...
любая помощь приветствуется
1>------ Build started: Project: OperatorsTypes, Configuration: Debug Win32 ------
1> main.cpp
1>c:\users\jorge\documents\visual studio 2010\projects\shapes\operatorstypes\operatorstypes\main.cpp(36): error C2259: 'Car' : cannot instantiate abstract class
1> due to following members:
1> 'void Vehicle::Move(void)' : is abstract
1> c:\users\jorge\documents\visual studio 2010\projects\shapes\operatorstypes\operatorstypes\main.cpp(9) : see declaration of 'Vehicle::Move'
1>c:\users\jorge\documents\visual studio 2010\projects\shapes\operatorstypes\operatorstypes\main.cpp(37): error C2259: 'Bus' : cannot instantiate abstract class
1> due to following members:
1> 'void Vehicle::Move(void)' : is abstract
1> c:\users\jorge\documents\visual studio 2010\projects\shapes\operatorstypes\operatorstypes\main.cpp(9) : see declaration of 'Vehicle::Move'
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========