EECE 2560 Lecture Notes - Function Overloading, Delimiter, Symbol Table
Document Summary
% contain data struct rectangle { int height; % member int weidth; % member. Rectangle r1; cin >> r1. height; cout << r1. width; They are always public time24::time24(int h, int m) hour = h; minute = m; normalizetime(); Default parameters time24 t1(7, 30) % time24 t1(7) > minute set to 0, time24 t1 > minute and hour both set to 0. // limitation: can"t set hour to 0 automatically. Function overloading void time24::addtime(int m) void time24::addtime( oat m) int main() tim24 t1(7,30); t1. addtime(10); % int input t1. addtime(10. 5); % oat input. % sometimes you want to use a function that can take an int or a oat, but you don"t want to write two separate functions to handle the two data types. Instead you can use function overloading that handles an int or a oat as an input, and the functions can have the same name.