#include <iostream>
using namespace std;
#include <string>
class Engine {
int power;
public:
Engine() {power=0;};
Engine (int pIn) { power = pIn;};
void show ();
float getPower () {return power;};
};
void Engine::show()
{
cout << " This is an engine have a power of " << power << " KWH " << endl;
return;
}
class Car : public virtual Engine {
int speed;
char mark [20];
float price;
public :
Car();
Car (int ,int ,char[],float);
void show();
float getSpeed () {return speed;};
char[] getMark() {return mark;};
float getPrice() {return price;);
};
Car :: Car():Engine () {
speed =0 ;
strcpy (mark, "" );
price = 0 ;
}
Car :: Car ( int pwIn, int sIn, char mIn[], float prIn) : Engine (pwIn){
speed =sIn;
strcpy (mark , mIn);
price = prIn;
}
void Car :: show ()
{
cout << " This is a " << mark << " having a speed of " << speed << " km/h,its power is"
<< getPower()<< "KWh and price is $ " << price << endl;
return ;
}
class PublicTransport : public virtual Engine{
float ticket ;
public :
PublicTransport();
PublicTransport (int, float ) ;
void (show);
float getTicket() {return ticket;} ;
};
PublicTransport :: PublicTransport () : Engine ()
{
ticket =0;
}
PublicTransport :: PublicTransport ( int pwIn , float tIn ) : Engine (pwIn){
ticket = tIn;
}
// gioi thieu
void PublicTransport :: show (){
cout << " This is a public tranport havin a ticket of $ " << ticket << " and its power is "
<< getPower()<< "Kwh" << endl;
return ;
}
class Bus : public Car, public PublicTransport {
int label;
public :
Bus();
Bus ( int, int, char [],float ,float,int);
void show();
};
Bus:: Bus () : Engine () ,Car(), Transport(){
label = 0 ;
}
Bus :: Bus ( int pwIn,int sIn, char mIn [], float prIn, float tIn, int lIn);
Engine (pwIn), Car (sIn, mIn, prIn ),PublicTransport ( tIn){
label = lIn;
}
void Bus::show(){
cout << " This is a bus on the line " << label << " ,its speed is " << getSpeed()
<< "km/h, power is " << Car::getPower()
<< " KWh,mark is " << getMark ()
<< " ,price is $ " << getPrice()
<< " and ticket is " << getTicket()<< endl;
return ;
}
void main ()
{
clarscr();
Bus myBus ( 250 ,100 , " Mercedes" ,3000, 1.5, 27 );
myBus.Car :: Engine :: show () ;
myBus.PublicTransport :: Engine :: show ();
myBus.PublicTransport :: show();
myBus.show ();
return ;
}
this is a mistake
23 F:\C++\Bus.cpp expected unqualified-id before '{' token