need help with problem

I am new to C++, and i am really lost in this chapter of fiends and overloading, have no idea how to program this, can anyone provide make the code for this so i can see how it is done so i can do it for the rest of the exercises???

Complete the following tasks:
a. Design a class to hold a JobBid. Each JobBid contains a bid number and a quoted price. Each JobBid also contains overloaded extraction and insertion operators.
b. Include an overloaded operator<() function. A JobBid is considered lower than another JobBid when the quoted price is lower.
c. Write a main() function that declares an array of four JobBid objects. Find and display the lowest JobBid. Save the file as JobBid. cpp.
You will need to overload the << and >> as top level functions so it would be best to have methods inside JobBid that return copies of the data you are going to use for the comparison. Then you don;t need to use friend functions which are just a shortcut and are generally bad OOP practice.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32

class Jobid {
public:
      Jobid(int initBid, int intiQuote ) { 
             if (intBid < 0)
                  initBid *= -1;   // make a negative bid positve
             if (initQuote < 0)
                  initQoute *= -1;   // same as above
            
             bid = initBid;            // store them
             qoute = initQoute; 
      }
      bool operator < (const Jobid& j) const { return qoute < j.qoute; }   
      int Bid() { return bid; }
      int Qoute { return qoute; }
private:
      int bid;
      int qoute;
};

//<<

osteam& operator << (ostream& out, const JobBid& j) {
      out << (output whatever here. use Bid() and Qoute() )

      return out;
}

//>>

//same thing except change the << to >> and change ostream to istream for input stream



Finish the osteam and istream and read son!

P.S - I didn't complile this so it could have errors.
Last edited on
thanks a million, and yes i should get c++ for dummies lol the text book doesnt help me a lot
Topic archived. No new replies allowed.