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 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104
|
#include "SingleRecipe.h"
#include "RecipeBook.h"
#include <iostream>
using namespace std;
int main()
{
int input = 0;
vector<SingleRecipe*> meow;
RecipeBook three(meow);
while (input != 5)
{
cout << "Main menu" << endl;
cout << "1. Add recipe" << endl;
cout << "2. Remove a recipe" << endl;
cout << "3. Print all recipes which have preparation time below a certain time" << endl;
cout << "4. Quit" << endl;
cout << "Select option: ";
cin >> input;
if (input == 1)
{
cout << "Please enter the recipe details: " << endl;
string name_input, end_input, endend_input;
vector<string> ingredient_input, method_input;
int servings;
double timeRequired;
cout << "Recipe name: ";
getline(cin, name_input);
cin.ignore();
while(end_input != "end")
{
cin.clear();
cin.sync();
cout << "Please enter ingredient #" << ingredient_input.size() + 1 << "(type 'end' to end): ";
getline(cin, end_input);
ingredient_input.push_back(end_input);
}
ingredient_input.pop_back();
while(endend_input != "end")
{
cin.clear();
cin.sync();
cout << "Please enter method #" << method_input.size() + 1 << "(type 'end' to end): ";
getline(cin, endend_input);
method_input.push_back(endend_input);
}
method_input.pop_back();
cout << "How many servings does this serve? ";
cin >> servings;
cout << "How much time does it require? ";
cin >> timeRequired;
cout << "Recipe added." << endl;
meow.push_back(new SingleRecipe(name_input, ingredient_input, method_input, servings, timeRequired));
three.addRecipe(new SingleRecipe(name_input, ingredient_input, method_input, servings, timeRequired));
}
else if (input == 2)
{
string remove_input;
cout << "Enter the name of the recipe you wish to remove: " << endl;
getline(cin, remove_input);
for (int i = 0; i < (signed int)meow.size(); i++)
{
if (meow[i]->getName() == remove_input)
{
meow.erase(meow.begin() + i);
cout << "Remove successful." << endl;
}
}
cout << "Recipe does not exist. Remove unsuccessful." << endl;
}
else if (input == 3)
{
double time_input;
cout << "Please enter the time for searching: ";
cin >> time_input;
vector<SingleRecipe*> hate;
hate.push_back(three.returnListOfRecipes(time_input));
if (!hate.empty())
{
cout << "List of recipes: " << endl;
for (int i = 0; i < (signed int)hate.size(); i++)
{
cout << hate[i]->toString() << endl;
}
}
else
{
cout << "Recipe does not exist." << endl;
}
}
else if (input == 4)
{
break;
}
}
return 0;
}
[code]
At Main.cpp, line 77, I get this error (I'm using VS2012):
[code]
no instance of overloaded function "std::vector<_Ty, _Alloc>::push_back [with _Ty=SingleRecipe *, _Alloc=std::allocator<SingleRecipe *>]" matches the argument list
argument types are: (std::vector<SingleRecipe *, std::allocator<SingleRecipe *>>)
object type is: std::vector<SingleRecipe *, std::allocator<SingleRecipe *>>
|