#include <iostream>
using namespace std;
class Wheel
{
public:
Wheel(int size);
int getDiameter();
protected:
int diameter;
};
Wheel::Wheel(int size)
{
diameter = size;
}
int Wheel::getDiameter()
{
return diameter;
}
class Bike : public Wheel
{
public:
Bike(int f, int b);
int getFrontsize();
int getBacksize();
bool operator==(Bike );
private:
Wheel front;
Wheel back;
};
//Bike::Bike(int f, int b):front(f), back(b)
//{
//}
Bike::Bike(int f, int b):Wheel(b), Wheel(f)
{
front =f ;
back = b ;
}
int Bike::getFrontsize()
{
return getDiameter();
}
int Bike::getBacksize()
{
return getDiameter();
}
bool Bike::operator==(Bike otherbike)
{
if (this->getFrontsize() == otherbike.getBacksize() )
return true;
return false;
}
int main()
{
Bike b(4,1);
Bike c(1,4);
Bike d(5,5);
Bike e(10,10);
cout << "The back size tyre is: " << b.getBacksize()<<endl;
cout << "The front size tyre is " << b.getFrontsize()<<endl;
if(b == c )
{
cout <<"The bikes are the same size"<<endl;
}
else
{
cout << "Nope you should'nt ride it!"<<endl;
}
if(d == e )
{
cout <<"The bikes are the same size"<<endl;
}
else
{
cout << "Nope you should'nt ride it!"<<endl;
}
return 0;
}
ok guys this is the error:
question 3 b.cpp
C:\computer science programming\CPP2\exam\question 3 b.cpp(45) : error C2512: 'Wheel' : no appropriate default constructor available
C:\computer science programming\CPP2\exam\question 3 b.cpp(45) : error C2512: 'Wheel' : no appropriate default constructor available
C:\computer science programming\CPP2\exam\question 3 b.cpp(45) : error C2437: 'Wheel' : already initialized
Error executing cl.exe.
for some reason it fails to work, I know its due to the constructor not passing the parameters correctly but can't figure it out