I am working with a bunch of classes with composition and I keep getting this error (Expected an identifier) when I try to implement the constructor , here the class header:
#ifndef STUDENT_H_
#define STUDENT_H_
#include "University.h"
class Student {
public:
Student(); // constructor
friend ostream & operator<<(ostream &, Student &); // print the student data
friend istream & operator>>(istream &, Student &); // to read student data
private:
const int id;
string name;
int marks[5];
Date admissionDate; // Composition
University university; // Composition
};
#endif
what do I need to do to solve this error ?
here's the cpp but I still did not implement the other io functions because I want to solve that error first..
#include "Student.h"
Student::Student(){}
ostream & operator<<(ostream &, Student &){}
istream & operator>>(istream &, Student &){}
Your constructor should be defined the following way
Student::Student() { /* some code */ }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With