Home > Back-end >  Why do I define the class member functions in the source file, but still an error "repeat defin
Why do I define the class member functions in the source file, but still an error "repeat defin

Time:09-27

 

The source file is as follows:
#include
#include
#include
# include "Student_info. H"
# include "grade. H"

STD: : istream& Read_hw (STD: : istream& In, STD: : vector Hw)
{
If (in)
{
Double x;
Hw. The clear ();

While (in & gt;> X)
Hw. Push_back (x);

In the clear ();
}

Return in;
}

Bool compare (const Student_info & amp; X, const Student_info & amp; Y)
{
Return x.g rade () & gt; Y.g rade ();
}

STD: : istream& Student_info: : read (STD: : istream& In)
{
In & gt;> N & gt;> Midterm & gt;> Final;
Read_hw (in homework);

Return in;
}

Const double Student_info: : grade ()
{
Return: : grade (midterm and final, homework);
}

The header file:
# # ifndef GUARD_Student_info_h
# define GUARD_Student_info_h

#include
#include
#include
# include "grade. H"

The class Student_info
{
Public:
STD: : istream& Read (STD: : istream&);
Const STD: : string name () {return n. }
Double grade () const;

Private:
STD: : string n;
Double midterm and final;
STD: : vector Homework;
};

STD: : istream& Read_hw (STD: : istream& , STD: : vectorBool compare (const Student_info & amp; , const Student_info & amp;);

#endif

CodePudding user response:

Header files define write complete, & the back of the variables? , the vector variable? Source file preach parameters directly variable names, with no type, this is not no you define, is to redefine, repeat to define the function or variable

CodePudding user response:

At which repeat definition, didn't see which repeat definition,

CodePudding user response:

You posted a few grade. J h, it may be in the header file

CodePudding user response:

Thank you, has been run successfully, I created a new project, copy the past
  • Related