菜鸟题,直接看下错误信息,帮我看下错在哪了好吗``谢谢了。
#include <iostream>
#include <string>
#include <cassert>
using namespace std;
class Name
{
public:
Name();
Name (string first,string middle,string last);
string getFirstName() const;
string getLastName() const;
string getMiddleName() const;
string getsignature() const;
void print(ostream& out) const;
private:
string myFirstName,
myMiddleName,
myLastName;
};
Name::Name(string first,string middle,string last)
{
myFirstName=first;
myMiddleName= middle;
myLastName= last ;
}
inline string Name::getFirstName() const
{
return myFirstName;
}
inline string Name::getLastName() const
{
return myLastName;
}
inline string Name::getMiddleName() const
{
assert (myMiddleName.size()>0);
return myMiddleName;
}
inline string Name::getsignature() const
{
return getFirstName()+' '
+getMiddleName()+"."
+getLastName();
}
inline void Name::print(ostream& out) const
{
cout <<getFirstName()+' '
+getMiddleName()+' '
+getLastName();
}
class Student:public Name
{
public:
Student();
Student(string first,string middle,string last,int id);
Student(string first,string middle,string last,int id,double wage,double hours);
Name getName() const;
int getIdNumber() const;
double getHoursWage() const;
double getHoursWorked() const;
void print(ostream& out) const;
private:
Name myName;
int myIdNumber;
double myHoursWage,
myHoursWorked;
};
inline Student::Student(string first,string middle,string last,int id)
{
myName=Name(first,middle,last);
myIdNumber=id;
myHoursWage=0.0;
myHoursWorked=0.0;
}
inline Student::Student(string first,string middle,string last,int id,double wage,double hours)
{
myName=Name(first,middle,last);
myIdNumber=id;
myHoursWage=wage;
myHoursWorked=hours;
}
inline Name Student::getName()const
{
return myName;
}
inline int Student::getIdNumber()const
{
return myIdNumber;
}
inline double Student::getHoursWage()const
{
return myHoursWage;
}
inline double Student::getHoursWorked()const
{
return myHoursWorked;
}
inline void Student::print(ostream& out)const
{
myName.print(out);
cout <<' ' <<getIdNumber()
<<' ' <<getHoursWorked()
<<' ' <<getHoursWage();
}
/*******************************/
驱动程序
#include <iostream>
#include "Student.h"
using namespace std;
void main()
{
Student oneStudent("Alex","Bob","Colt",1234,7.25,15.0),
anotherStudent("Debra","Ellen","Fazio",9876);
oneStudent.print(cout);
cout <<"\n";
anotherStudent.getName().print(cout);
cout <<' ' <<anotherStudent.getIdNumber() <<endl;
}
/*******************************/
错误信息:
例题.obj : error LNK2001: unresolved external symbol "public: __thiscall Name::Name(void)" (??0Name··QAEXZ)
Debug/书本211页.exe : fatal error LNK1120: 1 unresolved externals
执行 link.exe 时出错.