80 likes | 236 Views
ENEE150 Recitation 13. Attendance Word: cold. Outline. Project 4/ADTs Void pointers Function pointers. Abstract Data Types (ADTs). Line between user and person writing the code User uses the functions that you implement to perform task Create a hash table
E N D
ENEE150 Recitation 13 Attendance Word: cold
Outline • Project 4/ADTs • Void pointers • Function pointers
Abstract Data Types (ADTs) • Line between user and person writing the code • User uses the functions that you implement to perform task • Create a hash table • Similar to a class in object-oriented programming • Flexible
String • String • Data • Methods • compareTo • concat • equals • equalsIgnoreCase • length • toLowerCase • toUpperCase • All done for you!
Void Pointers • Generic pointer • Any normal pointer…except it can point to anything • Needs to be cast • (int *) • (char *) • Always dereference a void pointer with a cast! • Even when doing pointer arithmetic
Practice • Create a program that • Uses a void pointer • Void pointer is first set equal to integer a = 5 • Print the value of void pointer • Void pointer is set to char c = ‘c’ • Print the value of void pointer
Function Pointer • Points to functions… • The function parameters have to match the function pointer’s expected parameters • int (*func_ptr)(int, char, char) • Function it points to • intfunc(int, char, char)