Hey Everyone so I have the below code. Its a simple project and im just trying to practice classes in C++ and what not. The program semi works, but the only issue I have is that the printOrder() should be able to loop through the vector of Flavors and print out the order using the substring of the first 4 letters in the flavor.
Now the problem is that the vector is empty so when I print the order.. there's no orders.. and I know why, its because the vector that im passing in does not reference the private vector in the class. I don't know how to reference the vector in the class. Can anyone help? I'm pretty new to this so please be as detailed as possible, possibly with code examples? I might have butchered the structure of this class, but practice makers perfect.
Thanks everyone in advance.
#include "stdafx.h"
#include <iostream>
#include <string>
#include <vector>
#include <iomanip>
using namespace std;
    int number_small = 0;
    int number_medium = 0;
    int number_large = 0;
    int counter = 1;
    int vecCount = 1;
    class Order
{
public:
    //Default
    Order();
    //Paramerterized
    Order(string s, string flav,vector <string>& f)
    { 
    size = s;
    flavors = flav;
    x = f;
}
    //Functions
    void getYogurtSize(string s)
    {   LOOP:
            cout << "Please enter small, medium, or large: ";
            cin >> size;
            //If Statement
            if (size == "small")
            {   number_small++;}
            else if (size == "medium")
            {   number_medium++;}
            else if (size == "large")
            {   number_large++;}
            else    {   cout << "enter the correct input!\n\n"; 
            goto LOOP;} }
     void getYogurtFlavors(string flavor,vector<string> f)
    {
        vecCount = 1;
        do
        {
            cout << "\nEnter Flavor " << vecCount << ":";
            cin >> flavor;
            if (flavor == "DONE")
            {
                break;
            }
            f.push_back(flavor);  //Moved after the check to not include DONE
            vecCount++;
        } while ((flavor != "DONE") && (vecCount <= 10));
    }
void printOrder(vector<string> flavors)
{
    cout << "Order " << counter << ": ";
    for (auto i : flavors){
        cout << i.substr(0, 4) << "-";
    }
    cout << "**";
}
private:
   //Private Variables
   string size;
   string flavors;  
   vector <string> x;
};
int _tmain(int argc, _TCHAR* argv[])
{
//Variables
Order ord;
string sz;
string flavor;
string input;
vector <string> f;
const double TAX_RATE = 0.0875;
double subtotal;
double tax;
double total;
const double PRICE_SMALL = 2.19;
const double PRICE_MEDIUM = 3.49;
const double PRICE_LARGE = 4.49;
do
{
    ord.getYogurtSize(sz);
    ord.getYogurtFlavors(flavor, f);
    ord.printOrder(f);
    cout << "\n\nWould you like to add another order? ";
    counter++;
    cin >> input;
    f.clear();
} 
while (input == "yes");
{
    subtotal = (number_small*PRICE_SMALL) + (number_medium*PRICE_MEDIUM) + (number_large*PRICE_LARGE);
    tax = (subtotal*TAX_RATE);
    total = tax + subtotal;
    cout << "Subtotal: \t$" << fixed << setprecision(2) << subtotal << endl;
    cout << "Tax (8.75%):    $" << fixed << setprecision(2) << tax << endl;
    cout << "Total:   \t$" << fixed << setprecision(2) << total << endl << endl;
}
return 0;
}
//Default Constructor
Order::Order(){
size = "";
flavors = "";
}
 
    