Im having trouble creating a struct within a struct node. the program suppose to
hold students firstname, lastname, and gpa in a node therefore creating my linked list. Line 26 keeps saying that cannot convert parameter 2 from 'studentType to std::string
#include <iostream>
#include <string>
usingnamespace std;
struct studentType{
string firstname;
string lastname;
double gpa;
};
struct nodeType{
studentType info;
nodeType *link;
};
void insertFirst(nodeType *& head, string item);
int main(){
nodeType *nameshead = NULL;
studentType student1;
student1.firstname = "Mike";
student1.lastname = "Freel";
student1.gpa = 3.2;
insertFirst(nameshead,student1 );
system("pause");
return 0;
};
void insertFirst(nodeType *& head, studentType student)
{
// step 1. Make the "New node"
nodeType *newNode = new nodeType;
newNode->info = student; // set the "info" on the newNode to the "student" received via function paramter
// step 2. Set the "Link" of "new node" to the current "head"
newNode->link = head;
// step 3. Update "head" to now point to this "new node"
head = newNode;
}