Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class node;
- class list
- {
- public:
- void insert(string f, string l, int a);
- int length();
- private:
- node *head;
- int listlength;
- };
- class node
- {
- friend list;
- public:
- node(); // Null constructor
- ~node(); // Destructor
- void put(ostream &out); // Put
- bool operator == (const node &); // Equal
- bool operator < (const node &); // Less than
- private:
- string first, last;
- int age;
- node *next;
- };
- while (!infile.eof())
- {
- infile >> first >> last >> age;
- // Process if okay
- if (infile.good())
- a.insert(first, last, age);
- };
- void list::insert(string f, string l, int a)
- {
- node *temp1, *temp2 = head;
- temp1 = new node();
- temp1->first = f;
- temp1->last = l;
- temp1->age = a;
- temp1->next = NULL;
- if (listlength == 0)
- {
- temp1->next = head;
- }
- else
- while (temp2->next != NULL)
- {
- ;
- }
- }
- void sort(person b[], int count)
- {
- int i = 0, j = 0, indexofsmallest = i;
- person smallest = b[i];
- for (i = 0; i < count; i++)
- {
- smallest = b[i];
- indexofsmallest = i;
- for (j = i+1; j < count; j++)
- {
- if (b[j] < smallest)
- {
- smallest = b[j];
- indexofsmallest = j;
- }
- }
- //cstdlib swap function
- swap(b[i], b[indexofsmallest]);
- }
- }
Add Comment
Please, Sign In to add comment