struct Student
{
string name; // or char name[] with the max number of characters allowed in a name
double gpa;
double cur_Hours;
Student *next; //pointer to the next student
};
Student *head;
head = NULL;
i have this struct, and the pointer to the struct called head, yet when I compile (in VS) I get error messages, I cant seem to see what is wrong, surely I dont have to create a pointer for an oject of the struct Student?
(learning the basics of linked lists!)
error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
: error C2040: 'head' : 'int' differs in levels of indirection from 'Student *'
#include "stdafx.h"
#include <iostream>
usingnamespace std;
struct Student
{
string name; // or char name[] with the max number of characters allowed in a name
double gpa;
double cur_Hours;
Student *next; //pointer to the next student
};
Student *head;
head = NULL;
int main()
{
return 0;
}
No, it's that you can't have a statement outside of a function. The only things that can go outside functions are expressions and function definitions/declarations, as well as preprocessor macros.