"Function does not take two arguments"

#pragma once
#include <iostream>
#include <string>
#include <vector>
#include <stdlib.h>
#include <math.h>
#include <ctime>

using namespace std;

void initializeRestaurants(vector<string>&restaurants);
void printMenu();
int readMenuChoice();
void printRestaurants(vector<string>&restaurants);
string tournament(vector<string>&restaurants);
void addRestaurant(vector<string>&restaurants);
void removeRestaurant(vector<string>&restaurants);
void removeLoserRestaurant(string restaurantName, vector<string>& restaurants);
int find(string restaurantName, vector<string> restaurants);
void shuffleVector(vector<string> & restaurants);
const int NOT_FOUND = -1;

int main()
{
vector<string> restaurants;
initializeRestaurants(restaurants);
int choice = 0;
int menu = 0;

srand(time(0));

while (menu == 0)
{
printMenu();
choice = readMenuChoice();

if (choice == 1)
{
printRestaurants(restaurants);
}
if (choice == 2)
{
cout << "Enter a restaurant: ";
string restaurantName;
getline(cin, restaurantName);
addRestaurant(restaurantName, restaurants);
}
if (choice == 3)
{
cout << "Enter a restaurant: ";
string restaurantName;
getline(cin, restaurantName);
removeRestaurant(restaurantName, restaurants);
}
if (choice == 4)
{
cout << "The vector has now been shuffled" << endl;
shuffleVector(restaurants);

}
if (choice == 5)
{
cout << "The tournament begins: " << endl;
tournament(restaurants);

menu = -1;
}
if (choice == 6)
{
menu = -1;
return -1;
}
}

system("pause");
return 0;
}

void initializeRestaurants(vector<string>&restaurants)
{
restaurants.push_back("Cafe Rio");
restaurants.push_back("Olive Garden");
restaurants.push_back("Chick-Fil-A");
restaurants.push_back("Kneaders");
restaurants.push_back("Happy Sumo");
restaurants.push_back("Chipotle");
restaurants.push_back("Raising Canes");
restaurants.push_back("Chili's");
}

int find(string restaurantName, vector<string> restaurants)
{
for (int i = 0; i < restaurants.size(); i++)
{
if (restaurantName == restaurants[i])
{
return i;
}
}
return NOT_FOUND;
}

void addRestaurant(string restaurantName, vector<string>&restaurants)
{
int found = find(restaurantName, restaurants);
if (found == NOT_FOUND)
{
restaurants.push_back(restaurantName);
cout << "The restaurant " << restaurantName << " was added to the vector" << endl;
}
else
{
cout << "The restaurant " << restaurantName << " was not added because it already is there" << endl;
}
}

void printMenu()
{
cout << "1 - Display all restaurant" << endl;
cout << "2 - Add a restaurant" << endl;
cout << "3 - Remove a restaurant" << endl;
cout << "4 - Shuffle the vector" << endl;
cout << "5 - Begin the tournament" << endl;
cout << "6 - Quit the program" << endl;

}

int readMenuChoice()
{
int choice = 0;
cin >> choice;
string garbage = "";
getline(cin, garbage);
return choice;
}

void printRestaurants(vector<string>&restaurants)
{
for (int i = 0; i < restaurants.size(); i++)
{
if (i < restaurants.size() - 1)
{
cout << restaurants[i] << ",";
}
else
cout << restaurants[i];
}
}

void removeRestaurant(string restaurantName, vector<string>&restaurants)
{
int found = find(restaurantName, restaurants);
if (found != NOT_FOUND)
{
int last_position = restaurants.size() - 1;
restaurants.erase(restaurants.begin() + found);
cout << "The restaurant " << restaurantName << " was removed from the vector"<< endl;
}
else
{
cout << "The restaurant " << restaurantName << " was not removed because it was already in the vector" << endl;
}
}

void removeLoserRestaurant(string restaurantName, vector<string>& restaurants)
{
int found = find(restaurantName, restaurants);
if (found != NOT_FOUND)
{
int last_position = restaurants.size() - 1;
restaurants.erase(restaurants.begin() + found);
}
else
{
cout << "The restaurant " << restaurantName << " was not removed because it was not in the vector" << endl;
}
}

void shuffleVector(vector<string> & restaurants)
{
int maxShuffle = 100;
for (int shuffle = 0; shuffle < maxShuffle; shuffle++)
{
int position1 = rand() % restaurants.size();
int position2 = rand() % restaurants.size();
string temporary = restaurants[position1];
restaurants[position1] = restaurants[position2];
restaurants[position2] = temporary;
}
}

string tournament(vector<string>&restaurants)
{
const int POWER_BASE = 2;
int integerExponent = log(restaurants.size()) / log(POWER_BASE);
double doubleExponent = log(restaurants.size()) / log(POWER_BASE);
int i = 0;
vector<string> losers;
string restaurantName = "";

if (doubleExponent == integerExponent)
{
do
{
for (int i = 0; i < restaurants.size() - 1; i += 2)
{
string opponent1 = restaurants[i];
string opponent2 = restaurants[i + 1];
cout << endl << opponent1 << "vs. " << opponent2 << endl;
string winner;
getline(cin, winner);

while (winner != restaurants[i] && winner != restaurants[i + 1])
{
cout << "Invalid, please re-enter" << endl;
getline(cin, winner);

}
if (winner == opponent1)
{
restaurantName = opponent2;
losers.push_back(restaurantName);
}
else if (winner == opponent2)
{
restaurantName = opponent1;
losers.push_back(restaurantName);
}
}
for (int i = 0; i < losers.size(); i++)
{
restaurantName = losers[i];
removeLoserRestaurant(restaurantName, restaurants);
}
losers.clear();
printRestaurants(restaurants);
} while (restaurants.size() > 1);
cout << "The winner is " << restaurants[0] << endl;
}
else
{
cout << "Could not begin tournament. There is not enough restaurants in the tournament. Please add or remove a restaurant." << endl;
}
return restaurantName;
}
"Function does not take two arguments"

What function?

Line 16: Your function prototype for addRestaurant() states it takes one argument.

Line 46: You call addRestaurant() with two arguments. Your call must agree with the function prototype.

Line 17,53: Ditto for removeRestaurant().

Line 195: call to log () argument type is ambiguous. Argument type is unsigned int, but there is no overload of log() for unsigned int.

Line 196: ditto.

PLEASE USE CODE TAGS (the <> formatting button) when posting code.
It makes it easier to read your code and also easier to respond to your post.
http://www.cplusplus.com/articles/jEywvCM9/
Hint: You can edit your post, highlight your code and press the <> formatting button.




Last edited on
Thanks so much! It was the function problem. Didnt realize i had them different. Rookie mistake ;)
Topic archived. No new replies allowed.