Solidity Tutorial
Selected Reading
- Solidity - Discussion
- Solidity - Useful Resources
- Solidity - Quick Guide
- Solidity - Error Handling
- Solidity - Events
- Solidity - Assembly
- Solidity - Libraries
- Solidity - Interfaces
- Solidity - Abstract Contracts
- Solidity - Constructors
- Solidity - Inheritance
- Solidity - Contracts
- Solidity - Restricted Access
- Solidity - Withdrawal Pattern
- Cryptographic Functions
- Mathematical Functions
- Function Overloading
- Solidity - Fallback Function
- Solidity - Pure Functions
- Solidity - View Functions
- Solidity - Function Modifiers
- Solidity - Functions
- Solidity - Style Guide
- Solidity - Special Variables
- Solidity - Ether Units
- Solidity - Conversions
- Solidity - Mappings
- Solidity - Structs
- Solidity - Enums
- Solidity - Arrays
- Solidity - Strings
- Solidity - Decision Making
- Solidity - Loops
- Solidity - Operators
- Solidity - Variable Scope
- Solidity - Variables
- Solidity - Types
- Solidity - Comments
- Solidity - First Application
- Solidity - Basic Syntax
- Solidity - Environment Setup
- Solidity - Overview
- Solidity - Home
Selected Reading
- Who is Who
- Computer Glossary
- HR Interview Questions
- Effective Resume Writing
- Questions and Answers
- UPSC IAS Exams Notes
Function Overloading
Sopdity - Function Overloading
You can have multiple definitions for the same function name in the same scope. The definition of the function must differ from each other by the types and/or the number of arguments in the argument pst. You cannot overload function declarations that differ only by return type.
Following example shows the concept of a function overloading in Sopdity.
Example
pragma sopdity ^0.5.0; contract Test { function getSum(uint a, uint b) pubpc pure returns(uint){ return a + b; } function getSum(uint a, uint b, uint c) pubpc pure returns(uint){ return a + b + c; } function callSumWithTwoArguments() pubpc pure returns(uint){ return getSum(1,2); } function callSumWithThreeArguments() pubpc pure returns(uint){ return getSum(1,2,3); } }
Run the above program using steps provided in
chapter.Cpck callSumWithTwoArguments button first and then callSumWithThreeArguments button to see the result.
Output
0: uint256: 3 0: uint256: 6Advertisements