CS 24000 Lecture Notes - Lecture 21: Inline Function, Operator Overloading, In C

21 views3 pages

Document Summary

Cs 240 lecture 21 03302017-paramters, types and templates introduction. Default parameters: you can set default parameters, the default parameters should be the last one in a function declaration, example: void drawrect(int x, int y, int width=100, int height=100); drawrect(45, 67); // use defaults. drawrect(78, 96, 45); // Use default height only: only the declaration includes the default parameters and not the implementation. Overloading functions: also in c++ you can have multiple functions with the same name as long as the types of the arguments re different, when calling a function c++ will use the function that best matches the types. Operator overloading: you can also define your own operators in c+, for example, if you have a class class a { then you can define an operator. A operator + (const a &s1, const a &s2) { : and use it as:

Get access

Grade+20% off
$8 USD/m$10 USD/m
Billed $96 USD annually
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
40 Verified Answers
Class+
$8 USD/m
Billed $96 USD annually
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
30 Verified Answers

Related Documents