Hallo zusammen,
ich wuerde gerne meinen C Code in C++ umscheiben, bin in der C++ Materie aber leider noch voellig blind unterwegs. Kann mir da vielleicht jemand unter die Arme greifen?
Ich poste hier mal meinen ersten Abschnitt:
Vielen Dank schonmal fuer jede Hilfe!
ich wuerde gerne meinen C Code in C++ umscheiben, bin in der C++ Materie aber leider noch voellig blind unterwegs. Kann mir da vielleicht jemand unter die Arme greifen?
Ich poste hier mal meinen ersten Abschnitt:
Code:
#include "date.h"
#include "person.h"
#include "list.h"
#include <stdio.h>
/*a function to create some list content*/
void testlist1(plist *list)
{
person *p;
p = create_pexp("albert", "weiss", 3, 6, 2003);
add(list, p);
p = create_pexp("klaus", "kunze", 10, 5, 2003);
add(list, p);
p = create_pexp("albertus", "weiman", 2, 6, 2003);
add(list, p);
p = create_pexp("stefan", "adam", 10, 5, 2004);
add(list, p);
}
/*the main program whoch creates an empty list, adds some entries
* and searches and removes some elements, finally the list will be cleared*/
int main()
{
plist *list = create_empty_list();
testlist1(list);
print_l(list);
printf("----------------------------\n");
bubblesort(list, &pcmp_lastname);
printf("sorted by last name\n\n");
print_l(list);
bubblesort(list, &pcmp_firstname);
printf("sorted by firs tname\n\n");
print_l(list);
bubblesort(list, &pcmp_birthday);
printf("sorted by date of birth\n\n");
print_l(list);
print_l(list);
person* p = search_name(list, "albertus", "weiman");
remove_person(list, p);
delete_p(p);
/* only the pointer is removed from the list
* we have to delete person by calling delete_p*/
print_l(list);
p = search_date(list, create_d(10, 5, 2003));
remove_person(list, p);
delete_p(p);
print_l(list);
/*this function clears the list and deallocates all the memory including the stored data*/
clear_l(list);
print_l(list);
/*deallocating the memory for the list*/
free(list);
return 0;
}
Vielen Dank schonmal fuer jede Hilfe!