Function overloading identification – Computer Sir Ki Class

Login


Lost your password?

Don't have an account ?
Register (It's FREE) ×
  

Login
[lwa]



Exam Questions-CBSE12A-2018-02A #CPP#5231    siteicon   siteicon  

Problem Statement - Function overloading identification

Which function(s) out of the following can be considered as overloaded function(s) in the same program? Also, write the reason for not considering the other(s) as overloaded function(s).

void Execute(char A,int B); //Function 1
void Execute(int A,char B); //Function 2
void Execute(int P=10); //Function 3
void Execute(); //Function 4
int Execute(int A); //Function 5
void Execute(int &K); //Function 6

Solution

TC++ #5231

This question can have one of multiple answers.

Answer 1:
1, 2, 3 are overloaded and 4,5,6 are not.
4,5,6 will be ambiguous in relation to function 3.

Answer 2:
1, 2, 4,5 are overloaded and 3,6  are not.
3,6 would be ambiguous to function 5 as that also has one single int parameter.

Answer 3:
1,2,4,6 are overloaded and 3,5 are not.
3,5 would be ambiguous to as redeclaration error may come against function 6

 

Notes

  • Such question can have multiple answers for the reason that order is not determinable for such question when stray codes are provided.

Common Errors

  • Student often forget that overloading is never due to returned data type, it only depends on parameters passed to a function. It would be data type and cont of parameters.


Share

CSKC| Created: 3-Dec-2018 | Updated: 3-Dec-2018|CBSE12A-2018









×
Introductory Sessions Beginning to Program Tokens Keyword and Identifiers Data Types Variables and Constants Operators Simple User Input Building Expressions and Formulas Simple Real World Problems Simple If and If Else Multiple-Nested-Ladder of If Else Switch case selection Simple Loops Tricks in Loops - break continue scope Loop Applications - Handling numerals Series printing loops Nested Loops Pattern printing loops Number Varieties and Crunches String Handling (Null Terminated) Strings - string class type Functions (Built-in) Functions - user defined Functions Reference Passing/Returning Arrays Concepts and 1-D Arrays Array Data Management Two dimensional arrays and Matrices Structures Basics Structures passing/returning 2D Array Memory Addressing Display Using IO Manipulation Display Using C Formatting Tricks User Defined Data Types Enumerated Types Preprocessor Directives And Macros Exception Handling Programming Paradigms and OOPs Advantages Abstraction and Encapsulation Polymorphism Inheritance Function Overloading Concepts Function Overloading Varieties Function Overloading Special Cases Defining Classes Creating and Using Class Objects Class Members Accessibility Class Function Types Inline Functions Constant Functions Nesting of Functions Class Members Scope Resolution Static Members in a Class Array of Objects Constructor Concepts Default Constructor Parameterized Constructor Copy Constructor Constructor Overloading Destructors Inheritance Fundamentals Public Derivations Private and Protected Derivations Multiple Inheritance Multi-Level Inheritance Class Nesting Data File Concepts Handling Text Files Handling Binary Files Pointer Concepts Pointer and Arrays Pointers and Functions Object Pointers This Pointer Linked Lists Stacks Queues


Back