这个是一个名字的类。帮我看下哪错了?
类文件:
#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;
};
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();
}
/**********************/
驱动程序:
#include <iostream>
#include "Name.h"
using namespace std;
int main()
{
Name hisName("Hohn","Paul","Jones"),
herName("Mary","Anne","Smith");
cout <<hisName.getsignature()<<"\n\n";
herName.print(cout);
return 0;
}
/******************/
错误信息:
error LNK2001: unresolved external symbol "public: __thiscall Name::Name(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,class std::basic_string<char,struct std::char_traits<char>,class std::alloc
ator<char> >,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >)" (??0Name@@QAE@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@00@Z)
Debug/书本208.exe : fatal error LNK1120: 1 unresolved externals
执行 link.exe 时出错.