/*
Title : Lab Task 4 Question 3
Author : Lim Boon Jye
Description : Operator Overloading
Date : 13 September 2012
*/
#include <iostream>
#include <string>
usingnamespace std;
class Jobbid{
public:
int bidNum ;
double quotedPrice;
//Jobbid();
//~Jobbid();
//void displayLowest();
booloperator < (const Jobbid& j) const {
if( quotedPrice < j.quotedPrice ){
returntrue;
}
if( quotedPrice > j.quotedPrice ){
returnfalse;
}
}
//int Bid() { return bidNum; }
//int Qoute() { return quotedPrice; }
};
//void Jobbid :: displayLowest(){
//
//}
int main()
{
Jobbid thejobbid[4];
int arrayOfbid[4];
double priceQuoted[4];
for( int i = 0 ; i < 4 ; i++ ){
cout << "Enter Bid Number : ";
cin >> thejobbid[i].bidNum;
cout << "Enter quote price: ";
cin >> thejobbid[i].quotedPrice;;
}
for( int i = 0 ; i < 4 ; i++ ){
if ( thejobbid[i].quotedPrice < thejobbid[i+1].quotedPrice ){
cout << thejobbid[i+1].bidNum << " more than " << thejobbid[i].bidNum <<endl;
}
elseif ( thejobbid[i].quotedPrice > thejobbid[i+1].quotedPrice ){
cout << thejobbid[i+1].bidNum << " less than " << thejobbid[i].bidNum <<endl;
}
}
cin.ignore();
cin.get();
return 0;
}
My code is wrong . can any senior try to help?
I've to create 4 array of the Object
I have to display the lowest Quoted price with their Bid Number ID
Have to use overloaded operator <()
Cannot use constructor to set field values
so , where my code wrong?
My sample out
1 2 3 4 5 6 7 8 9 10 11 12
Enter Bid Number : 0413
Quoted Price : 50.00
Enter Bid Number : 0414
Quoted Price : 50.05
Enter Bid Number : 0415
Quoted Price : 60.00
Enter Bid Number : 0416
Quoted Price : 20.00
Lowest Price Quote is : RM 20
Bid Number ID is : 0416
but I not really sure how to do it.. need to use overloaded array