fork download
  1.  
  2. #include <iostream>
  3. using std::cout;
  4. using std::endl;
  5.  
  6. void OneParam(int);
  7. void TwoParams(int, int=666);
  8.  
  9. void A() {
  10. //The following is an error...
  11. //OneParam();
  12. TwoParams(999); //calls TwoParams(999, 666)
  13. }
  14.  
  15. void OneParam(int n = 666) {
  16. cout << n << endl;
  17. }
  18.  
  19. void TwoParams(int i=999, int j) { //lolwut? Default parameters have to be at the end!
  20. cout << i << " " << j << endl;
  21. }
  22.  
  23. void B() {
  24. OneParam(); //calls OneParam(666)
  25. TwoParams(); //calls TwoParams(999, 666)
  26. }
  27.  
  28. int main() {
  29. A();
  30. B();
  31. }
  32.  
Success #stdin #stdout 0s 2724KB
stdin
Standard input is empty
stdout
999 666
666
999 666