I am trying to implement a vector of a class that when certain inputs from the user are keyed in, elements are assigned via a member function while simultaneously "pushing back" or increasing the size of the vector of the object. This is my second course in c++ but still really a novice when it comes to classes and how to do certain things with them. I've searched the forum and reference sections and can't find anything that would help.
My current code compiles and runs but it iterates back to the "while" loop as I believe it exits the for loop but I can't quite figure out why. I'm sure the answer is simple but can't get my head around it.
To reiterate, I think my current problem is "pushing back" (increasing the size of the vector when I assign the object members user given values) the vector.
class Order
{
int bidPrice;
int lots;
int acctNum;
public:
Order (int bidPrice, int lots, int acctNum);
Order ();
void assignOrder (int , int, int);
void printOrder ();
//void assignPrice (int newPrice);
//void assignLots (int newLots);
//void assignAcct (int newAcct);
bool executable(int offerPrice);
void execute(void);
};
//Order Orders;
int main ()
{
vector <Order> orders;
//Order tmpOrder;
int bPrice;
int bLots;
int bAcct;
int i;
string logOff;
while (logOff != "Quit")
{
cout << "Welcome to the Financial Instrument Order System\n";
cout << "To exit the program at any time, please type Quit\n";
cout << "Please Enter Your Order\n";
cout << "Price Lots Account Number\n";
cout << "_____ ____ ______________\n";
cin >> bPrice >> bLots >> bAcct;
for (int i=0; i < orders.size(); i++)
{
orders.push_back(orders[i]);
orders[i].assignOrder(bPrice, bLots, bAcct);
orders[i].printOrder();
cout << "\n";
}
}
return 0;
}
void Order::assignOrder(int bPrice, int bLots, int bAcct)
{
bidPrice = bPrice;
lots = bLots;
acctNum = bAcct;
}