Home > Back-end >  Please help me to see a program
Please help me to see a program

Time:10-22

//define a header file first Date. H
# # ifndef DATE_H
# define DATE_H
The class Date
{
Private:
Int day, month, year;
Public:
Void init (void);
Void setdata (void);
Void the output (void);
};
# endif
//Date. CPP definition function of the Date class
#include
# include "Date. H"
using namespace std;
Void Date: : init (void)
{
Day=1; The month=1; Year=2007;
}
Void Date: : setdata (void)
{
Cin> Year> Month> Day;
}
Void Date: : the output (void)
{
Cout}
//define a header file Person. H
# # ifndef PERSON_H
# define PERSON_H
#include
using namespace std;
# include "Date. H"
The class Person
{
Private:
This char name [20], a [20], address [50]; Int the age;
The Date Birthday;
Public:
Void init1 Date (p);
Void setdata1 Date (p);
Void output1 (void);
};
# endif
//Person. CPP definition function of the Person class:
#include
#include
using namespace std;
# include "Person. H"
Void Person: : init1 (Date) p
{
Strcpy (name, "None");
Strcpy (job, "None");
Strcpy (address, "None");
Age=0;
Birthday=p;
}
Void Person: : setdata1 (Date) p
{
Cin> Name> Job> Address> age;
Birthday=p;
}
Void Person: : output1 (void)
{
CoutBirthday. The output (void);
Cout}
//main program:
//class mix. CPP: defines the entry point of the console application,
//

# include "stdafx. H"
#include
# include "Date. H"
# include "Person. H"
using namespace std;

Int _tmain (int arg c, _TCHAR * argv [])
{
The Date of p;
The Person student;
P.i nit (); Student. Init1 (p);
Student. Output1 ();
P. etdata (); Student. Setdata1 (p);
Student. Output1 ();
return 0;
}
Run after the prompt:
Mix class. Obj: error LNK2019: cannot resolve the external symbol of "public: void __thiscall Person: : setdata1 (class Date)" (? Setdata1 @ Person @ @ QAEXVDate @ @ @ Z), the symbol referenced in the function _wmain
1> Mix class. Obj: error LNK2019: cannot resolve the external symbol of "public: void __thiscall Date: : setdata (void)" (? Setdata @ Date @ @ QAEXXZ), the symbol referenced in the function _wmain
1> Mix class. Obj: error LNK2019: cannot resolve the external symbol of "public: void __thiscall Person: : output1 (void)" (? Output1 @ Person @ @ QAEXXZ), the symbol referenced in the function _wmain
1> Mix class. Obj: error LNK2019: cannot resolve the external symbol of "public: void __thiscall Person: : init1 (class Date)" (? Init1 @ Person @ @ QAEXVDate @ @ @ Z), the symbol referenced in the function _wmain
1> Mix class. Obj: error LNK2019: cannot resolve the external symbol of "public: void __thiscall Date: : init (void)" (? Init @ Date @ @ QAEXXZ), the symbol referenced in the function _wmain
1> C: \ Users \ \ Administrator \ documents \ visual studio 2010 \ Projects \ mixing \ Debug \ class mix. Exe: fatal error LNK1120: five cannot resolve external commands

CodePudding user response:

Person of the definition in each header file, that is, class declaration
  • Related