0

プログラムを実装しようとすると、Person::Person への未定義参照というリンカ エラーが発生します。3つの部分は以下です。私は今数時間それを修正するために取り組んできました。おそらく、私が見ていない単純なものであることはわかっています。しかし、私はインターネットを見回しましたが、まだ答えが見つかりません。そのため、どんな助けもいただければ幸いです。

#ifndef PERSON0_H_
#define PERSON0_H_

#include <string>

class Person // class declaration
{
private:
    static const int LIMIT = 25;
    std::string lname;
    char fname[LIMIT];
public:
   Person() {lname = ""; fname[0] = '\0';}
   Person(const std::string & ln, const char * fn = "Hay you");
   void Show() const;
   void FormalShow() const;
};

#endif

#include <iostream> 
#include <string>
#include "person0.h"


void Person::Show() const
{
 using namespace std;

      std::cout << fname << " " << lname << '\n';

}           

void Person::FormalShow() const
{
 using std::cout;

      std::cout << lname << ", " << fname << '\n';
}




#include <iostream>
#include <string>
#include "person0.h"

int main()
{
using namespace std;

Person one;
Person two("Smythecraft");
Person three("Dimwiddy", "Sam");
one.Show();
cout << endl;
one.FormalShow();
cout << endl;
two.Show();
cout << endl;
two.FormalShow();
cout << endl;
three.Show();
cout << endl;
three.FormalShow();        


cin.get();
cin.get();
return 0;
}
4

1 に答える 1

4

私は実際には C++ の人ではないので、用語が間違っているかもしれませんが、

Person::Person(const std::string & ln, const char * fn)

コンストラクターがありません。

于 2013-03-24T23:18:33.927 に答える