hi.

i am looking to run the following queries from the project zipped with this message:

1. List all lecturers in alphabetic order by surname within a selected department.
2. List all lecturers within a selected faculty.
3. List all modules taught by a selected lecturer.

i am having trouble doing these and was hoping to be pointed in the right direction. any help in this would be extremely appreciated.

Dani AI

Generated

Given the three files called out (lecturer.h/.cpp, faculty.h/.cpp and main.cpp) the usual, robust pattern is: make a stable link between Lecturer and Faculty (an id or a Faculty*), filter the lecturer collection by that link, then sort the filtered list by surname. was right to ask for scope — focus changes only inside the Lecturer/Faculty classes and the display code in main.cpp.

A compact C++ approach (conceptual):

auto getSurname = [](const std::string &full){
  size_t p = full.find_last_of(' ');
  return (p==std::string::npos) ? full : full.substr(p+1);
};

std::vector<const Lecturer*> lecturersInFaculty(int facultyId,
                                                const std::vector<Lecturer> &all){
  std::vector<const Lecturer*> out;
  for (const auto &L : all)
    if (L.facultyId == facultyId) out.push_back(&L);
  std::sort(out.begin(), out.end(),
            [&](const Lecturer* a, const Lecturer* b){
              return getSurname(a->fullName) < getSurname(b->fullName);
            });
  return out;
}

For "modules taught by a lecturer", either give Lecturer a std::vector<int> moduleIds or store lecturerId on Module and filter modules the same way. Notes: store surname separately if possible (avoids fragile parsing), use case-insensitive compare for real sorting, and avoid returning pointers to temporaries (keep the source container alive or return indices/references). If data lives in a database, the equivalent is a JOIN with ORDER BY surname.

Recommended Answers

All 2 Replies

Like a more specific question than "I've got problems, and here's a 3/4 Meg ZIP file for you to dig through" ?

im sorry.

basically, the problem i want to know how to solve, is to find a way to list all lecturers in a certain faculty.

so the only files that need looking at are lecturer.h/.cpp, faculty.h/.cpp and main.cpp

i am unsure how to display more than 1 file at a time, as i can easily display lecturers on theire own, or faculty on its own. but i dont know how to find all lecturers in a certain faculty.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.