So my goal is to pass this vector vector 'Beer' allBeers to a function UnitedStatesBeer::getBeerTop(), but when I try to do that, I get the error that there's too many arguments in function call, or my object is not initialized.
How do I fix this? Thanks for your help!
#include <iostream>
#include <fstream>
#include <string>
#include <iomanip>
#include <vector>
using namespace std;
class RatingCalculator
{
public:
virtual void showCountryTop() = 0;
virtual void getCountryTop() {};
};
class Beer
{
public:
string name;
string rating;
string country;
string alc;
string type;
};
class UnitedStatesBeer : public RatingCalculator
{
private:
string name;
string rating;
string country;
string alc;
string type;
public:
void showCountryTop() {};
void getCountryTop(vector<Beer> allBeers){};
int main()
{
ifstream file("beer.txt");
Beer currentBeer;
vector<Beer> allBeers;
for (int i = 0; !file.eof(); i++)
{
getline(file, currentBeer.name, '\t');
getline(file, currentBeer.rating, '\t');
getline(file, currentBeer.country, '\t');
getline(file, currentBeer.alc, '\t');
getline(file, currentBeer.type, '\n');
allBeers.push_back(currentBeer); //copy all the information to allBeers vector
}
file.close();
/*if I do it this way*/
UnitedStatesBeer UsReassign;
UsReassign->getCountryTop(allBeers); //<- expression (UsReassign) must have pointer type/ Using uninitialized memory
// RatingCalculator* UsReassign = new UnitedStatesBeer();
// UsReassign-> getCountryTop(allBeers); //<- too many arguments in function call
}