Vector Errors in C++ Program -


i working on miscellaneous theater seating program! starting progress through c++, can't figure out these errors. trying make program store user entered row numbers , row seats (only if multiple seats) in 2 vectors; vector seat_row() , vector seat_number(). know error stating, don't know how approach situation otherwise. sorry if being unclear, honest, don't know else include. please take @ code, feel program, , let me have ideas. please keep answers simple; again, i'm no master @ c++

p.s.

sorry showing whole code... didn't know include, not to; , wanted people able feel program testing themselves... again!

/*   * program built team of students  * local movie theaters sell tickets  *   * file: main.cpp  * author(s):  *  *   * created on april 15, 2013, 11:10  */   #include <cstdlib> #include <vector> #include <string> #include <fstream> #include <iostream> #include <cctype> #include <iomanip>  using namespace std;  //function prototypes void title_card(); void seating_prices(); void seating_chart(); void pick_seating(); void purchase_history(); void quit(); void update_file(); void show_menu(); void picking_seats(); void display_seating(); void display_name(); void display_number_of_seats(); void display_correct1(string, int); void display_seats(); void display_correct2(string, int, int, int); void display_correct2_alt(string, int, vector<int>, vector<int>); void display_correct3(string); void multiple_seats(string, int, vector<int>, vector<int>); void display_rows_seats(string, int); void display_finished(string); void display_purchase_seats(string, int, int); void display_purchase_seats_alt(string, int, vector<int>, vector<int>);  int readseating (const char*, vector<char>&); //reads seatingchart.txt int readprices(string, vector<double>&); //reads seatingprices.txt vector<double> prices(15); //for seatprices.txt vector<char> seating(450); //for seatingchart.txt  vector<int> seat_row(); //for storing multiple seat rows vector<int> seat_number(); //for storing multiple seat numbers    //actual program int main() {     title_card(); //calls title page      readseating("seatingchart.txt", seating); //reads seatingchart.txt     readprices("seatprices.txt", prices); //reads seatprices.txt     show_menu(); //shows introductory menu      system ("pause");     return 0; }     //************************************************************** // definition of showmenu function. shows introductory menu* // , controls user ends in program.             * //**************************************************************   void show_menu() { int choice; string password;        cout << "welcome our theater program! made person" << endl;       cout << "who looking seating, purchasing ticket, and" << endl;       cout << "searching other miscellaneous things... hope" << endl;       cout << "you enjoy program!" << endl << endl;       cout << "below list of options user can choose from:" << endl << endl;       cout << "1.\tseating prices" << endl;       cout << "2.\tseating chart" << endl;       cout << "3.\tpick seating" << endl;       cout << "4.\tpurchase history" << endl;       cout << "5.\tquit" << endl << endl;       cout << "enter choice... (1-5): ";       cin >> choice;          while (choice < 1 || choice > 5){             cout << endl << "you have entered invalid choice!" << endl;             cout << "enter choice... (1-5): ";             cin >> choice;                  }           switch (choice){              case 1:                   seating_prices();               case 2:                   seating_chart();               case 3:                   pick_seating();               case 4:                   purchase_history();               case 5:                   quit();                   }                   }       //************************************************************** // definition of seating_prices function. displays  * // user, seatprices.txt                                        * //**************************************************************   void seating_prices(){     system ("cls");     cout << "the current seating prices are:" << endl << endl;     (int count = 0; count < 4; count++){     cout << " " << setprecision(4) << showpoint <<  prices[count] << " | row " << (count + 1) << endl;     }     (int count = 4; count < prices.size(); count++){     cout << "  " << setprecision(3) << showpoint <<  prices[count] << " | row " << (count + 1) << endl;     }     cout << endl;     system ("pause");     system ("cls");     show_menu(); }    //************************************************************** // definition of seating_chart function. function      * // displaying seating chart                      * //**************************************************************  void seating_chart(){       system ("cls");      int counter = 30;      int row_counter = 0;       cout << "the current seating chart is:" << endl << endl << endl << "           1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0" << endl << endl;     cout << "         ---------------------------------------------------------------" << endl;      cout << " row " << (row_counter + 1) << "     ";      //displaying seating chart      (int index = 0; index < 270; index++){             if (index == counter){             row_counter = (row_counter + 1);             counter = (counter + 30);             cout << "" << endl << " row " << (row_counter + 1) << "     ";              }           cout << seating[index] << " ";          }              (int index = 270; index < seating.size(); index++){           if (index == counter){             row_counter = (row_counter + 1);             counter = (counter + 30);             cout << "" << endl << " row " << (row_counter + 1) << "    ";              }           cout << seating[index] << " ";          }      cout << endl << "         ---------------------------------------------------------------" << endl;            cout << endl << endl;          system ("pause");          system ("cls");          show_menu();          }     //************************************************************** // definition of pick_seating function. displays       * // current seating chart , allows user pick seat* //**************************************************************   void pick_seating(){  //not finished      system ("cls");     display_seating();  }     //************************************************************** // definition of purchase_history function. displays   * // current total sum of movie ticket purchases         * //**************************************************************   void purchase_history(){         //not finished      system ("cls");      system ("pause");      system ("cls");      show_menu(); }    //************************************************************** // definition of quit function. allows user quit the* // program entirely                                            * //**************************************************************   void quit(){      update_file();      exit(0);      }     //************************************************************** // definition of update_file function. designed update  * // seating chart upon leaving pick_seating function    * //**************************************************************    void update_file(){  //not finished       //this function supposed      //update seating chart      //upon exit of pick_seating function      }     //************************************************************** // definition of read_prices function. reads seatprices.txt  * // , stores pre-determined prices vector named    * // prices.                                                     * //**************************************************************    int readprices(string myfile, vector<double>& vect) {      //input file     ifstream seatprices;                         seatprices.open(myfile.c_str());       //if file cannot found     if (!seatprices)      cout << "cannot find file!" << endl;       (int index = 0; index < vect.size(); index++){         seatprices >> vect[index];   //reading file "seatprices.txt"         }      seatprices.close();  //closes file     return 0; }     //************************************************************** // definition of readseating function. reads text file   * // seating chart in it.                                 * //**************************************************************    int readseating(const char* myfile, vector<char>& vect){       //input file     ifstream seatingchart;     seatingchart.open(myfile);      //if file cannot found     if (!seatingchart)     cout << "cannot find file!" << endl;      (int index = 0; index < vect.size(); index++){         seatingchart >> vect[index];  //reading file "seatingchart.txt"         }      seatingchart.close(); //closes file     return 0; }     //************************************************************** // definition of display_seating function. function    * // simplifying pick_seating function                       * //**************************************************************   void display_seating(){       int counter = 30;      int row_counter = 0;       //displaying seating chart     cout << "           1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0" << endl << endl;     cout << "         ---------------------------------------------------------------" << endl;      cout << " row " << (row_counter + 1) << "     ";      //displaying seating chart      (int index = 0; index < 270; index++){             if (index == counter){             row_counter = (row_counter + 1);             counter = (counter + 30);             cout << "" << endl << " row " << (row_counter + 1) << "     ";              }           cout << seating[index] << " ";          }              (int index = 270; index < seating.size(); index++){           if (index == counter){             row_counter = (row_counter + 1);             counter = (counter + 30);             cout << "" << endl << " row " << (row_counter + 1) << "    ";              }           cout << seating[index] << " ";          }      cout << endl << "         ---------------------------------------------------------------" << endl << endl;        cout << "in seating chart... hashtags (#'s) seats taken" << endl;      cout << "and stars (*'s) available seats..." << endl << endl;      system ("pause");        display_name(); //continues program, helps loop if necessary      }    //************************************************************** // definition of display_name function. function       * // simplifying pick_seating function                       * //**************************************************************   void display_name(){       string name;       //picking seat     cout << endl << endl << "to pick own seat(s), follow instructions below:" << endl << endl;     cout << "what name of recipient of seat(s)? ";     cin >> name;       display_correct3(name);     }    //************************************************************** // definition of display_number_of_seats function. function* // simplifying pick_seating function                   * //**************************************************************   void display_number_of_seats(string name){       int number_of_seats;      int available_seats = 450; //amount of remaining seats out of 450       cout << "alright " << name << "!" << endl;      cout << "how many seats purchasing today? ";      cin >> number_of_seats;          while (number_of_seats < 1 || number_of_seats > available_seats){               cout << endl << endl << "you have entered invalid number of seats!" << endl;               cout << "this might because number 0 or less," << endl;               cout << "or number entered more amount" << endl;               cout << "of remaining seats! try again!" << endl << endl;               cout << "how many seats purchasing today? ";               cin >> number_of_seats;               }          display_correct1(name, number_of_seats);         }   //************************************************************** // definition of display_correct1 function. function   * // simplifying pick_seating function                       * //**************************************************************   void display_correct1(string name, int number_of_seats){       int correct;       cout << endl << "alright " << name << ", purchasing " << number_of_seats << " seat(s)?" << endl;      cout << "is correct? enter '0' 'no', or '1' yes: ";      cin >> correct;          while (correct < 0 || correct > 1){         cout << "you have entered invalid number!" << endl;         cout << "enter '0' 'no', or '1' yes: ";         cin >> correct;         }          if (correct == 0){            cout << endl << endl;            display_number_of_seats(name);            }          if (correct == 1){            cout << endl << endl;             if (number_of_seats > 1)            multiple_seats(name, number_of_seats, seat_row, seat_number);             display_rows_seats(name, number_of_seats);            }         }     //************************************************************** // definition of multiple_seats function. function    * // used if user chooses purchase multiple seats             * //**************************************************************   void multiple_seats(string name, int number_of_seats, vector<int> vect, vector<int> vect2){       (int index = 1; index <= number_of_seats; index++){       (int count = 0; count < number_of_seats; count++){       cout << "for seat #" << index << "..." << endl;       cout << "enter row number in: (1-15): ";                   cin >> vect[count];           while (vect[count] < 1 || vect[count] > 15){           cout << endl << "you have entered invalid row number!" << endl;           cout << "enter row number in (1-15): ";           cin >> vect[count];           }            cout << "enter seat number have (1-30): ";           cin >> vect2[count];                while (vect2[count] < 1 || vect2[count] > 30){               cout << endl << "you have entered invalid seat number!" << endl;               cout << "enter seat number have (1-30): ";               cin >> vect2[count];               }      cout << endl;      }      }      display_correct2_alt(name, number_of_seats, seat_row, seat_number);      }     //************************************************************** // definition of display_rows_seats function. function * // simplifying pick_seating function                       * //**************************************************************  void display_rows_seats(string name, int number_of_seats){       int seat_choice;      int row_choice;        cout << "enter row number in: (1-15): ";                   cin >> row_choice;           while (row_choice < 1 || row_choice > 15){           cout << endl << "you have entered invalid row number!" << endl;           cout << "enter row number in (1-15): ";           cin >> row_choice;           }            cout << "enter seat number have (1-30): ";           cin >> seat_choice;                while (seat_choice < 1 || seat_choice > 30){               cout << endl << "you have entered invalid seat number!" << endl;               cout << "enter seat number have (1-30): ";               cin >> seat_choice;               }       display_correct2(name, number_of_seats, row_choice, seat_choice); //helps looping if necessary       }     //************************************************************** // definition of display_correct2_alt function. alternate  * // function if user enters multiple seats                      * //**************************************************************   void display_correct2_alt(string name, int number_of_seats, vector<int> vect, vector<int> vect2){       int correct;      int counter = 1;      int counter_2 = 1; //for minor details looks       (int index = 1; index <= number_of_seats; index++){         (int count = 0; count < number_of_seats; count++){        if (counter_2 != number_of_seats && counter_2 == 1){         //for first seat       cout << endl << endl << "alright " << name << ";" << endl;      cout << "for seat #" << index << "; chose " << "row #" << vect[count];      cout << " , seat #" << vect2[count] << "?" << endl;      cout << "is correct? enter '0' 'no', or '1' yes: ";      cin >> correct;       }        if (counter_2 != number_of_seats && counter_2 > 1){         //for seats after first, except last seat       cout << endl << endl;      cout << "next, seat #" << index << "; chose " << "row #" << vect[count];      cout << " , seat #" << vect2[count] << "?" << endl;      cout << "is correct? enter '0' 'no', or '1' yes: ";      cin >> correct;       }        if (counter_2 == number_of_seats){         //for last seat       cout << endl << endl;      cout << "and last seat, seat #" << index << "; chose " << "row #" << vect[count];      cout << " , seat #" << vect2[count] << "?" << endl;      cout << "is correct? enter '0' 'no', or '1' yes: ";      cin >> correct;      }      }            while (correct < 0 || correct > 1){         cout << "you have entered invalid number!" << endl;         cout << "enter '0' 'no', or '1' yes: ";         cin >> correct;         }           if (correct == 0){            cout << endl << endl;             if (number_of_seats > 1)            multiple_seats(name, number_of_seats, seat_row, seat_number);             display_rows_seats(name, number_of_seats);            }          if (correct == 1){            if (counter == number_of_seats)            display_purchase_seats_alt(name, number_of_seats, seat_row, seat_number);            }          counter = (counter + 1);         counter_2 = (counter_2 + 1);       }      }   //************************************************************** // definition of display_correct2 function. function   * // simplifying pick_seating function                       * //**************************************************************   void display_correct2(string name, int number_of_seats, int row_choice, int seat_choice){       int correct;       cout << endl << endl << "alright " << name << ", chose " << "row #" << row_choice;      cout << " , seat #" << seat_choice << "?" << endl;      cout << "is correct? enter '0' 'no', or '1' yes: ";      cin >> correct;          while (correct < 0 || correct > 1){         cout << "you have entered invalid number!" << endl;         cout << "enter '0' 'no', or '1' yes: ";         cin >> correct;         }          if (correct == 0){            cout << endl << endl;             if (number_of_seats > 1)            multiple_seats(name, number_of_seats, seat_row, seat_number);             display_rows_seats(name, number_of_seats);            }          if (correct == 1)            display_purchase_seats(name, row_choice, seat_choice);         }     //************************************************************** // definition of display_purchase_seats function. function * // user purchase chosen seats                           * //**************************************************************   void display_purchase_seats(string name, int row_choice, int seat_choice){       int total_cost = 0; //not set yet; supposed calculate row price       system ("cls");      cout << name << ", time pay chosen seats!" << endl;      cout << "since chose row #" << row_choice << ", , seat# " << seat_choice << "..." << endl;      cout << "your total cost is: s" << total_cost << endl << endl;       system ("pause");       display_finished(name);      }     //************************************************************** // definition of display_purchase_seats_alt function.      * // alternate function used purchasing multiple seats       * //**************************************************************   void display_purchase_seats_alt(string name, int number_of_seats, vector<int> vect, vector<int> vect2){       int total_cost = 0; //not set yet; supposed calculate row price       system ("cls");      cout << name << ", time pay chosen seats!" << endl;      cout << "since chose " << number_of_seats << " seats:" << endl << endl;       (int index = 0; index <= number_of_seats; index++){       cout << "seat #" << index << " being in row #" << seat_row[index] << ";" << endl;      }       cout << endl << "your total cost is: $" << total_cost << endl << endl;      system ("pause");       display_finished(name);      }        //************************************************************** // definition of display_correct3 function. function   * // simplifying pick_seating function                       * //**************************************************************   void display_correct3(string name){       int correct;       cout << endl << "alright, chose name " << name << "?" << endl;      cout << "is correct? enter '0' 'no', or '1' yes: ";      cin >> correct;          while (correct < 0 || correct > 1){         cout << "you have entered invalid number!" << endl;         cout << "enter '0' 'no', or '1' yes: ";         cin >> correct;         }          if (correct == 0){            system ("cls");            display_seating();            }          if (correct == 1){            cout << endl;            display_number_of_seats(name); //helps if looping necessary            }         }     //************************************************************** // definition of display_finished function. function   * // simplifying pick_seating function                       * //**************************************************************   void display_finished(string name){       system ("cls");       cout << "congratulations " << name << "! have picked seat!" << endl;      cout << "the seating chart update momentarily..." << endl << endl;      update_file();      system ("pause");      system ("cls");      show_menu();       }    //************************************************************** // definition of title_card function. starts program   * // title card, showing little introductory title      * //**************************************************************   void title_card(){      cout << endl << endl << endl << endl;      cout << "\t\t" << "************************************************\n";      cout << "\t\t" << "*               theater seating!               *\n";      cout << "\t\t" << "*                                              *\n";      cout << "\t\t" << "*     program created team of 3     *\n";      cout << "\t\t" << "*     students small theaters sell     *\n";      cout << "\t\t" << "*                 more tickets                 *\n";      cout << "\t\t" << "*                                              *\n";      cout << "\t\t" << "*              team of students:               *\n";      cout << "\t\t" << "*                                              *\n";      cout << "\t\t" << "*                                              *\n";      cout << "\t\t" << "*                                              *\n";      cout << "\t\t" << "*                                              *\n";      cout << "\t\t" << "*                                              *\n";      cout << "\t\t" << "************************************************\n";      cout << endl << endl;      system ("pause");      system ("cls");      } 

your error here

vector<int> seat_row(); //for storing multiple seat rows vector<int> seat_number(); //for storing multiple seat numbers 

it should be

vector<int> seat_row; //for storing multiple seat rows vector<int> seat_number; //for storing multiple seat numbers 

it's common error, trying declare 2 vectors called seat_row , seat_number, because used empty parens instead declared 2 functions return vectors.

here's summary

vector<int> a(10); // vector, size 10 vector<int> b(0);  // vector, size 0 vector<int> c;     // vector size 0 vector<int> d();   // function!! taking no arguments , returning vector 

Comments

Popular posts from this blog

c# - Send Image in Json : 400 Bad request -

jquery - Fancybox - apply a function to several elements -

An easy way to program an Android keyboard layout app -