There is a code, at rantayme gives a segmentation error:
#include <iostream> using namespace std; class StudentList { private: class Student { private: string name; int age; double height; public: Student *next; explicit Student(string n,int a,double h): name(n), age(a), height(h) {} string getName() { return name; } int getAge() { return age; } double getHeight() { return height; } ~Student() {} }; Student *temp; public: explicit StudentList() { temp=NULL; } ~StudentList() { } void list() { Student* student=temp; while(student) { cout<<temp->getName()<<"\t"<<temp->getAge()<<"\t"<<temp->getHeight()<<"\n"; temp=temp->next; } //delete student; } void insertValue(string name,int age,double height) { Student *student=new Student(name,age,height); student->next=temp; temp=student; } }; int main() { StudentList ls; ls.insertValue("Falcao",45,1.87); ls.insertValue("Jacob",97,3.87); ls.list(); } The problem is in the function sheet ..