🔥Limited Offer: Get 50% OFFon AI & Full Stack Courses🔥
Back to C++ Notes
Topic #75

Default Parameter


Default Parameter Value

You can also use a default parameter value, by using the equals sign (=).

If we call the function without an argument, it uses the default value ("Norway"):

Example

void myFunction(string country = "Norway") {
  cout
<< country << "\n";
}

int main() {
  myFunction("Sweden");

myFunction("India");
  myFunction();

myFunction("USA");
  return 0;
}

// Sweden
//
India
// Norway
// USA

Note: A parameter with a default value, is often known as an "optional parameter". From the example above, country is an optional parameter and "Norway" is the default value.

Want to go beyond the notes?

Join CodingNow 2.0's C++ course — live mentorship, real projects, and 100% placement support.

Enroll Now — Free Demo Available

Default Parameter – FAQs

Quick answers about learning Default Parameter in C++.

This free note from CodingNow 2.0 explains Default Parameter in C++ — concept, syntax and worked code examples you can copy, run and revise before interviews.
Yes. Every C++ topic on CodingNow 2.0, including Default Parameter, is 100% free with no signup required.
With focused practice, most students grasp Default Parameter in 1–3 days from these notes; pairing it with CodingNow 2.0's mentor-led course takes you to job-ready depth faster.
Use the code examples in this note, then ask doubts for free on the CodingNow 2.0 Community (/community) — expert instructors answer within 24 hours.
WhatsApp
Call NowEnroll Now