Home > Back-end >  [for] C topic is: define the Student class and class Score, the output of a Student transcript (incl
[for] C topic is: define the Student class and class Score, the output of a Student transcript (incl

Time:09-26

I write so (using VS2013) :

Student. H

 # pragma once 
#include
using namespace std;

The class Student
{
Public:
Student (string num, string name)
{
This - & gt; Num=num;
This - & gt; Name=name;
}
To the Student ();
Void ShowData (Score & amp;);
Private:
String num.
String name;
};


Student. CPP

 # include "stdafx. H" 
H # include "Student."
# include "Score. H"
# include & lt; Iostream>
using namespace std;

Student: : ~ Student ()
{
}

Void Student: : ShowData (Score & amp; Stu)
{
Cout & lt; <"==========the student information \ n";
Cout & lt; Cout & lt; <"\ n name: \ t" & lt; Cout & lt; <"\ n high number: \ t" & lt; Cout & lt; Cout & lt; Cout & lt; <"\ nC++ : \ t" & lt; Cout & lt; <"\ n===================\ n";
}


Score. H

 # pragma once 
The class Student.

The class Score
{
Public:
Score (float Math, float English, float Politics says, float Cplusplus)
{
This - & gt; Math=Math;
This - & gt; English=English;
This - & gt; Politics says=Politics says;
This - & gt; Cplusplus=Cplusplus;
}
To Score ();
Friend void Student: : ShowData (Score & amp;);
Private:
Float Math;
Float English;
Float Politics says;
Float Cplusplus;
};


Score. CPP

 # include "stdafx. H" 
# include "Score. H"

Score: : ~ Score ()
{
}


lab 3. CPP

 # include "stdafx. H" 
# include "Score. H"
H # include "Student."
# include & lt; String>
# include & lt; Iostream>
using namespace std;

Int _tmain (int arg c, _TCHAR * argv [])
{
String num, name;
Float math, English, politics says, cpluslus;
Cout<" Please enter the student id, name, and mathematics, English, politics and c + + : \ n ";
Cin & gt;> Num & gt;> The name & gt;> Math & gt;> English & gt;> Politics says & gt;> Cpluslus;
Student stu (num, name);
Score stu1 (math, English, politics says, cpluslus);
Stu. ShowData (stu1);
return 0;
}


But in Student. CPP file ShowData function referenced in the Score display an error when data members


Then when debugging the compiler hint has the following error:
Error 1 error C2027: use the undefined type "Student" c: \ users \ XXXX \ documents \ visual studio 2013 \ projects \ experiment three \ \ score three h 17 1 lab 3
Error 2 error C2061: syntax errors: identifier "Score" c: \ documents \ \ users \ XXXX visual studio 2013 \ projects \ three experiments for three \ \ student h 16 1 lab 3
Error 3 error C2245: will not exist a member function "Student: : ShowData" designated as friend yuan (with all overloaded member function signature does not match) c: \ documents \ \ users \ XXXX visual studio 2013 three \ test \ \ projects \ experiment score. 17 1 lab 3 h
Mistake 4 error C2511: "void Student: : ShowData (Score & amp;) ":" Student "found no overloaded member function in c: \ users \ XXXX \ documents \ visual studio 2013 \ projects \ experiment three \ \ Student three CPP 12 1 lab 3
Error 5 error C2597: the non-static member "Student:" num "illegal reference to c: \ documents \ \ users \ XXXX visual studio 2013 \ projects \ experiment three \ \ Student three CPP 14 1 lab 3
Error 6 error C2597: the non-static member "Student:" name "of illegal reference to c: \ users \ XXXX \ documents \ visual studio 2013 \ projects \ experiment three \ \ Student three CPP 15 1 lab 3
Error and the error C2248: "Score: : Math" : unable to access private members (statements) in the "Score" class c: \ documents \ \ users \ XXXX visual studio 2013 \ projects \ experiment three \ \ student three CPP 16 1 lab 3
8 error error C2248: "Score: : English:" can't access private members (statements) in the "Score" class c: \ documents \ \ users \ XXXX visual studio 2013 \ projects \ experiment three \ \ student three CPP 17 1 lab 3
Error error of 9 C2248: "Score: : Politics says:" don't have access to private member (statements) in the "Score" class c: \ documents \ \ users \ XXXX visual studio 2013 \ projects \ experiment three \ \ student three CPP 18 1 lab 3
Error 10 error C2248: "Score: : Cplusplus" : unable to access private members (statements) in the "Score" class c: \ documents \ \ users \ XXXX visual studio 2013 \ projects \ experiment three \ \ student three CPP 19 1 lab 3
Error and the error C2027: use the undefined type "Student" c: \ documents \ \ users \ XXXX visual studio 2013 \ projects \ experiment three \ \ score three h 17 1 lab 3
12 IntelliSense: do not allow the use of incomplete type c: \ Documents \ \ Users \ XXXX Visual Studio 2013 \ Projects \ experiment three \ \ Score three h 17 14 experiment three

Excuse me, where is wrong? The two class how to declare?