0

I was just wondering how I would compare 2 different object member of the same class. I want to compare the int speed between the 2 objects.

Lets say I have a

class Car
{
private:
          int speed;
public:
        int compare(Car car)
}

main()
{
    Car Honda, Toyota;

    //Lets say I have declared Honda.speed = 5 Toyota.speed   =   10      

Honda.Compare(Toyota);

}

int Car::compare(Car car)
{
   if(this->speed > //What do i put here to compare the speed? )
      cout << "this car is faster";
   if(this->speed <  //???? )
      cout << "this car is slower";
}
1
Contributor
1
Reply
2
Views
7 Years
Discussion Span
Last Post by Instinctlol
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.