title: collect2:ld returned 1 exit status error
body: <p>I'm writing basic C++ code to practice using <code>fstream</code> and header files. I keep getting the following error:</p>
  
  <blockquote>
    <p>initializer.cpp:(.text+0xd9): undefined reference to `DataSet::DataSet(int, std::basic_string, std::allocator >, std::basic_string, std::allocator >, double)'
    collect2: ld returned 1 exit status</p>
  </blockquote>
  
  <p>Here's the main:</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;fstream&gt;
  #include &lt;cstdlib&gt;
  #include "dataset.h"
  using namespace std;
  
  int main()
  {
    ofstream outData("data.txt",ios::binary);
  
    if(!outData)
    {
      cerr&lt;&lt;"\nFile could not be opened!\n";
      exit(1);
    }
  
    DataSet blankData;
  
    for(int i=0;i&lt;100;i++)
      outData.write(reinterpret_cast&lt;const char *&gt;(&amp;blankData),
        sizeof(DataSet));
  
    return 0;
  }
  </code></pre>
  
  <p>and the header:</p>
  
  <pre><code>#ifndef DATASET_H
  #define DATASET_H
  
  #include &lt;string&gt;
  using namespace std;
  
  class DataSet
  {
  public:
    DataSet(int=0,string="",string="",double=0.0);
  
    void setAccountNumber(int);
    int getAccountNumber() const;
  
    void setLastName(string);
    string getLastName() const;
  
    void setFirstName(string);
    string getFirstName() const;
  
    void setBalance(double);
    double getBalance() const;
  private:
    int accountNumber;
    char lastName[15];
    char firstName[10];
    double balance;
  };
  
  #endif
  </code></pre>
  
  <p>and the corresponding .cpp:</p>
  
  <pre><code>#include &lt;string&gt;
  #include "dataset.h"
  
  DataSet::DataSet(int accountNumberValue,
    string lastNameValue,string firstNameValue,
    double balanceValue)
  {
    setAccountNumber(accountNumberValue);
    setLastName(lastNameValue);
    setFirstName(firstNameValue);
    setBalance(balanceValue);
  }
  
  int DataSet::setAccountNumber(int accountNumberValue)
  {
    accountNumber=accountNumberValue;
  }
  
  void DataSet::getAccountNumber() const
  {
    return accountNumber;
  }
  
  string DataSet::setLastName(string lastNameString)
  {
    const char *lastNameValue=lastNameString.data();
    int length=lastNameString.size();
    length=(length&lt;15?length:14);
    strncpy(lastName,lastNameValue,length);
    lastName[length]='\0';
  }
  
  void DataSet::getLastName() const
  {
    return lastName;
  }
  
  string DataSet::setFirstName(string firstNameString)
  {
    const char *firstNameValue=firstNameString.data();
    int length=firstNameString.size();
    length=(length&lt;10?length:9);
    strncpy(firstName,firstNameValue,length);
    firstName[length]='\0';
  }
  
  void DataSet::getFirstName() const
  {
    return firstName;
  }
  
  double DataSet::setBalance(double balanceValue)
  {
    balance=balanceValue;
  }
  
  void DataSet::getBalance() const
  {
    return balance;
  }
  </code></pre>