I need help comparing an array that is stored within a class. It has to be a member function and include the parameters set by my professor. I am having trouble calling the function as well as comparing it.
I included this function to show how I was able to compare the company name and return true or false when they were equal. I then looped through to find all the cars in a print function in the list that were of the same brand.
bool AutoVehicleType::isMadeByCompany(string companyName){
if (companyName.compare(getAutoBrand())==0)
return true;
else return false;
}
void printAllVehiclesMadeBy(AutoVehicleType vehicles[], int
noOfVehicles,string brand){
for(int i=0; i<noOfVehicles;i++){
if(vehicles[i].isMadeByCompany(brand)){
vehicles[i].printVehicleInfo();
cout << endl << "---------------" << endl;
//loop that prints if vehicles made by the same brand
}
}
}
This is the function that I am trying to make. I need help comparing the function as well as calling the member functions from the class. I am trying to make it similar to the one I made bove but I am having issues since it is an array and dont know how to compare it using the parameter set by my teacher.
bool AutoVehicleType::HaveIdenticalAmenities(AutoVehicleType
otherVehicles){
if(vehicles[i].amenities==otherVehicles.amenities)
return true;
else return false;
}
void printVehiclesWithIdenticalAmenities(AutoVehicleType
vehicles[], int noOfVehicles){
for (int i = 0; i < noOfVehicles; i++)
{
if(vehicles[i].HaveIdenticalAmenities(otherVehicles))
{
cout<<"Vehicles "<<Vehicles[i].getNumPlate()<<"
and "<< otherVehicles[].getNumPlate()<<" Have
Identical set of Amenites";
}
}
}
I get a lot of undeclared identifier errors when fiddling with these functions becuase I'm guessing I dont know how to call them correctly.