#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

Bike (incorrectly) derives from Wheel, so you need to supply a constructor call to the base class. If one isn't make explicitly, it's provided for you using the default constructor. Try this:

Bike::Bike(int f, int b): Wheel(0), front(f), back(b) {}

Of course, 0 is probably not an appropriate value.

Bike (incorrectly) derives from Wheel, so you need to supply a constructor call to the base class. If one isn't make explicitly, it's provided for you using the default constructor. Try this:

Bike::Bike(int f, int b): Wheel(0), front(f), back(b) {}

Of course, 0 is probably not an appropriate value.

but then every value is set to 0. Can you expand on incorrectly derives from Wheel please?

>Can you expand on incorrectly derives from Wheel please?
A bike isn't a wheel, it has wheels, so containment is the better option:

class Bike {
public:
  //...
private:
  Wheel front, back;
};
This article has been dead for over six months. Start a new discussion instead.