fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. void f(int a=1); // forward declaration with a default value for the compilation unit
  5. void f(int a) // definition
  6. {
  7. cout<<a<<endl;
  8. }
  9. void g() {
  10. void f(int a=2); // declaration in the scope of g
  11. f();
  12. }
  13. int main() {
  14. f(); // uses general default => 1
  15. g(); // uses default defined in g => 2
  16. return 0;
  17. }
Success #stdin #stdout 0s 15232KB
stdin
Standard input is empty
stdout
1
2