Hello Guys,
I have a bit of confusion about how to define a searching function.Here is what I wanted to do, I need to define the searching function which takes the name of a student as (stated in the argument) and returns a pointer to that or NULL if the name is found.

Student *students = NULL;//Defined as a global varibale and intiated as NULL and defined the class like below.

class Student
{
private:
    string  Name;
    string  ID;
    string  *next;
public:
    Student(string, string, Student *)
    {
        string Name;
        string ID(" ");
        Student *next(NULL);
    }
    string get_name()
    {
        return Name;
    }
    string get_next()
    {
        return ID;
    }

    friend ostream& operator<<(ostream &out, Student &st)
    {
        out << st.Name << ", ID number: " << st.ID;

        return out;

    }
};
// Global function to search a student
Student *searchstudent(string Name)
{
    //TO DO
}

Thanks a lot ! :)

Is your student class also a linked list?

commented: Yes it is. +0
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.