How to get my CSV File reader to read different types in C++?

For my project, my program has to read a file that looks like this: “Mary”, “000111222”, “Junior”, 12, 4.0
In my main code it can read it, but only as strings only. I want it to read it as string,string, string, float, float. The getLine() method only works with strings. I tried other ways but it did not work. Any suggestions? The fields I want to be a float is gpa and credit. Any advice is appreciated! Thank you!

#include <iostream>
#include <string>
#include <iterator>
#include <iomanip>
#include <fstream>
#include <vector>
include <sstream>
#include <algorithm>


using namespace std;

class Student {

  //declare local variables
  protected:
string name;    //people with names longer than 21 characters will just have 
                  to make do
string ssn;     // Social Secturity Number. 
string gpa;     //Most up to date gpa for the student
string credits; //Number of student's credit hours

                //build public methods
public:

//Default Constructor
Student() {}


 //Student constructor. Besides the character arrays, everything else is 
 passed by reference.
  Student(const string n, const string s, string sGPA, string sCredits) {

    name = n;
    ssn = s;
    gpa = sGPA;
    credits = sCredits;
}
string getName() {
    return name;
}
string getSSN() {
    return ssn;
}
string getGPA() {
    return gpa;
}
string getCredit() {
    return credits;
}
//a function that is expected to be implemented and overridden by subclasses
virtual void print() const {

    cout << '\n' << endl;
    cout << "Student's name: " << name << endl;
    cout << "Student SSN: " << ssn << endl;
    cout << "Student's current GPA: " << gpa << endl;
    cout << "Student's credit hours: " << credits << endl;
  }


// a pure virtual function for implementation later. Makes whole class 
Abstract
virtual float tuition() const = 0;
 };

  class Undergrad : public Student {

//declare local variables

  protected:
  float undergrad_rate = 380.0;
  string year;


  //build public methods

  public:

 //Default Constructor
 Undergrad() {}


//Undergrad Constructor
 Undergrad(const string n, const string s, string uGPA, string uCredits, 
 string y) :
    Student(n, s, uGPA, uCredits), year(y) {}


//Display the contents of undergrad
void print() const {
    Student::print();
    cout << "Undergrad Rate: " << undergrad_rate << endl;
    cout << "Year: " << year << endl;
}


//Display undergrad's current year
string get_year() {
    return year;
}


//Display the undergrad's current rate
float get_rate() {
    return undergrad_rate;
}


//Set a undergrad's current year
void set_year(string y) {
    year = y;
}


//Display the cost for an undergrad to attend university
float tuition() const {
    return 1000000;
}
};



int main() {
ifstream ip("data.txt");

if (!ip.is_open()) std::cout << "ERROR: File not found" << '/n';
string name;
string ssn;
string year;
string credit;
string gpa;

vector<Undergrad> file;
//Undergrad g(name, ssn, year, credit, gpa);
while (ip.good()) {
    getline(ip, name, ',');
    getline(ip, ssn, ',');
    getline(ip, gpa, ',');
    getline(ip, credit, ',');
    getline(ip, year, '\n');

    //  float number = stoi(gpa);
    //float number1 = stoi(credit);
    Undergrad g(name, ssn, year, credit, gpa);
    file.push_back(g);







}
ip.close();
Undergrad g = file.back();
file.pop_back();
file.insert(file.begin(),g);



for (int i = 0; i < file.size(); i++) {
    cout << "Name: " << file[i].getName() << endl;
    cout << "SSN: " << file[i].getSSN() << endl;
    cout << "Year: " << file[i].get_year() << endl;
    cout << "Credit:  " << file[i].getCredit() << endl;
    cout << "GPA " << file[i].getGPA() << endl;
    cout << " " << endl;


}



system("pause");
return 0;

}

How to get my CSV File reader to read different types in C++?