I am trying to initialize a Student object and I keep getting an undefined reference error despite having the class definitions in my header file.
I have the C++ file student.cpp:
class Student {
private:
    double gpa;
public:
    Student(double g) : gpa(g) {};
    double getGPA() {return gpa;}
};
The associated header file student.h:
#ifndef STUDENT_H
#define STUDENT_H
class Student 
{
private:
    double gpa;
public:
    Student(double);
    double getGPA();
};
#endif
And the C++ source file main.cpp:
#include "student.h"
int main() {
    Student myStudent(4.0);
    return 0;
}
I am running the command g++ main.cpp student.cpp to link the source files. It keeps giving an error:
"main.cpp:(.text+0xe): undefined reference to `Student::Student(double)".
Why is this happening?
 
     
    