So the nullptr error doesnt show up when i compile it at school and i think i can fix it with adding a line when i compile it, is there another way to get rid of it, and the other two errors i dont understand why im getting them at all. Can someone explain at least the nullptr error?
main.cpp: In function 'int main()':
error: 'array' was not declared in this scope
error: 'hours' was not declared in this scope
error: 'nullptr' was not declared in this scope
int main()
{
float *studentData;
int numStudents;
int size;
int average = getAverage(*array, *hours);
int median = getMedian(hours);
int mode = getMode(hours);
cout << "How many students were surveyed? ";
cin >> numStudents;
studentData = makeArray(numStudents);
if (studentData == nullptr)
cout << "Error allocating memory.";
else
{
getFBData(studentData, numStudents);
selectionSort(studentData, numStudents);
for (int i = 0; i < numStudents; i++)
cout << *(studentData + i) << endl;
delete[] studentData;
}
getAverage(*array, hours);
printArray(size, hours);
getMedian(*array, hours);
getMode(*array, hours);
cout << "STATISTICS " << endl;
cout << "\n Mean: " << average;
cout << "\n Median: " << median;
cout << "\n Mode: " << mode;
return 0;
}
nullptr
supposed to be declared? – guestnullptr
is a keyword in C++11 – M.MNULL
is a macro that expands to0
. So that works too (so long as you're including a header that definesNULL
). – M.M