Default Arguments in C++ Functions - Syntax and Examples
In C++, a default argument is a value provided in a function declaration that is automatically used when the caller does not supply a corresponding argument. Default arguments make function calls more flexible and reduce the need to define multiple functions for similar tasks. C++ में Default Argument वह Value होती है जिसे Function Declaration में पहले से निर्धारित किया जाता है। जब Function Call करते समय संबंधित Argument नहीं दिया जाता, तो Function उस Default Value का उपयोग करता है। इससे Function Call अधिक Flexible बनता है और समान कार्यों के लिए अलग-अलग Functions बनाने की आवश्यकता कम हो जाती है। Syntax of Default Arguments – डिफॉल्ट आर्गुमेंट का सिंटैक्स return_type function_name(data_type parameter = value) { // Statements } Here, value is the default value assigned to the parameter. The caller can provide another value when calling the function. यहाँ value , Parameter को दी गई Default Value है। Function Call करते समय Caller चाहे तो इसके स्थान पर दूसरी Value भी दे सकता है। Exampl...