I am trying to learn more about vectors and store objects in it. I am reading data from the txt file. I cannot see what mistake I'm making that it does not work.
Here are my main methods
void Reader::readFoodFile() {
    string name;
    int cal, cost;
    ifstream file;
    file.open("food.txt");
    while (file >> name >> cal >> cost) {
        Food f(name, cal, cost);
        foodStorage.push_back(f); 
    } 
}
void Reader::getStorage() {
    for (unsigned int i = 0; i < foodStorage.size(); i++) {
        cout << foodStorage[i].getName();
    }
}
And here is my Food constructor:
Food::Food(string newName, int newCalories, int newCost) {
    this->name = newName;
    this->calories = newCalories;
    this->cost = newCost;
}
In my main.cpp file I'm just creating the object Reader(no constructor now) and call the methods.
int main(int argc, char** argv) {
        Reader reader;
        reader.readFoodFile();
        reader.getStorage();
}
I want to populate the Vector with objects that take data from the txt file and then print it out(for now).
Any suggestions?
edit; my .txt file layout is
apple 4 2
strawberry 2 3
carrot 2 2
Here is my Food.h and Reader.h
#ifndef FOOD_H
#define FOOD_H
#include <string> 
#include <fstream>
#include <iostream>
using namespace std;
class Food {
public:
    Food();
    Food(string, int, int);
    Food(const Food& orig);
    virtual ~Food();
    string getName();
    int getCalories();
    int getCost();
    void setCost(int);
    void setCalories(int);
    void setName(string);
    int calories, cost;
    string name;
private:
};
#endif  /* FOOD_H */`
and Reader.h
`#ifndef READER_H
#define READER_H
#include <string> 
#include <fstream>
#include <iostream>
#include <vector>
#include "Food.h"
using namespace std;
class Reader {
public:
    Reader();
    Reader(const Reader& orig);
    virtual ~Reader();
    void readFoodFile();
    void getStorage();
    vector<Food> foodStorage;
private:
};
#endif  /* READER_H */
 
     
    