Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

answer these short questions Equations of motion D Digolet - Bachelor of Enginee

ID: 2247132 • Letter: A

Question


answer these short questions

Equations of motion D Digolet - Bachelor of Engineer O Watch Harry Potter A Shokuge You may be asked to demonstrate/explaln your work to the tutor, If you are absent/unavailable or fall to demonstrate property, zero marks will be awarded Text book: Deiltel, H M & Deitel, P J 2013, C: How to program, 7th edn, Pearson Prentice-Hall, Upper Saddle River, New Jersey Week 11 enables C++ to have various functions with the same name that operate on (symbol) enables access to a global variable with the same name as a variable in enables a single function to be defined to perform the same task on da ta of different types or numbers of arguments 2. The ii a particular function. 3. A many different types 4. Explain what the purpose of default argument is 5. Write a program that uses a function template called max to determine the larger of two arguments 6. Write another function template called min to determine the smaller of two arguments 7. Test the program using integer, character and floating-point number arguments 8. Determine whether the following program segments contain error(s), then for each error found explain how to correct it a. template k class A> inf sum( int numi, int num2, int num return numl num2 +num3 template kA A product A numi, A num2,A num3 return num num2 num3

Explanation / Answer

Answer 1. Function overloading

By using Function overloading We can use multiple function with same name and different argument. for example:

void func(int p, int q) { }

void func(float q, int q) { }

void func(int p, int q, int r) { }

Answer2. scope resolution operator (::). enable access a global variable if we have a local and global variable with same name

Answer3:By using template we can create a single function or a class to work with different data types.

In large codebase for the purpose of code reusability and flexibility of the programs. Templates are often used

Answer4: Value of the dafault argument is provided in the function declaration. If caller of the function doesn't provide a value for the argument with default value then the compiler automatically assigned it.Once default value is used for an argument, all subsequent arguments must have default value.