Searching through text files
<p>I need some help. I am to write a reporting system in C++
and the part of the system I need help with is to be able to: 
List all lecturers in alphabetic order by surname within a selected department.</p>

<p>I got 2 different text files as shown below with some data:</p>

<p>Department text file:</p>

<pre><code>Department (identifier, name, foreign key)

ET  Engineering and Technology      AT

BE  Built Environment           AT

CMS Computing and Mathematical Sciences AT
</code></pre>

<p>Lecturers text file:</p>

<pre><code>Lecturer (identifier, surname, forename, foreign key)

RG  Garwood         Roy     ET

BM  Muller      Bertie      CMS

SL  Lloyd       Steve       BE
</code></pre>

<p>How do I search for information and collect what I need from two different text files that are linked?</p>

<p>Below is part of some code of the system</p>

<p>Part of main.cpp</p>

<pre><code>void listoflecturerbydepartment()
{
    int Department;

    // Display message asking for the user input
    std::cout &lt;&lt; "List all lecturers by surname within a selected department" &lt;&lt; std::endl;
    std::cout &lt;&lt; "Enter your preferred department." &lt;&lt; std::endl;
    std::cout &lt;&lt; "Either of the following: ET, BE, CMS, SAS, CS and PESD:" &lt;&lt; std::endl;

    // Read in from the user input
    std::cin &gt;&gt; Department;

    // Search for all lecturers by their surname with the selected department

    // Read from text file and Display list of lecturers

    std::ifstream infile;           // enable to open, read in and close a text file
    std::string LecturerSurname;
    infile.open("Lecturer.txt");    // open a text file called Lecturer

    if (!infile)                

    {
        std::cout &lt;&lt; "Item list is empty" &lt;&lt; std::endl;     // if the file is empty it output the message
    } 
    else 
    {
        std::cout &lt;&lt; "List of Lecturers: " &lt;&lt; std::endl;        

        while(!infile.eof())                                // output the description of the text file onto the screen
            //(iter != itemList-&gt;end()) 
        {
            getline(infile,LecturerSurname);
            std::cout &lt;&lt; LecturerSurname &lt;&lt; std::endl;
            //iter++;
        }
        std::cout &lt;&lt; "End of list\n" &lt;&lt; std::endl;
    }

    infile.close();         // close the text file

}
</code></pre>

<p>Department.h file</p>

<pre><code>#pragma once
#include &lt;iostream&gt;
#include &lt;string&gt;

class department
{
public:
    float DepartmentCode;
    std::string DepartmentName;
private:
    department(void);
    ~department(void);
    department(float DepartmentCode, std::string DepartmentName);
    std::string getDepartmentName(void);
};
</code></pre>

<p>Lecturer.h file</p>

<pre><code>#pragma once
#include &lt;iostream&gt;
#include &lt;string&gt;

class lecturer
{
public:
    float LecturerCode;
    std::string LecturerSurname;
    std::string LecturerForename;
private:
    lecturer(void);
    ~lecturer(void);
    lecturer(float LecturerCode, std::string LecturerSurname, std::string LecturerForename);
    std::string getLecturerSurname(void);
};
</code></pre>

<p>Now updated with new code</p>
