fork(2) download
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. class A {
  6. public:
  7. void sender();
  8. private:
  9. unsigned int score = 10;
  10. };
  11.  
  12. class B {
  13. public:
  14. void receiver(unsigned int & score = 10);
  15. };
  16.  
  17. void A::sender() {
  18. cout << "Before: " << score << endl;
  19. B b;
  20. b.receiver(score);
  21. cout << "After: " << score << endl;
  22. }
  23.  
  24. void B::receiver(unsigned int & score) {
  25. score = 100;
  26. }
  27.  
  28. int main() {
  29. A a;
  30. a.sender();
  31. return 0;
  32. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp:14:39: error: could not convert ‘10’ from ‘int’ to ‘unsigned int&’
  void receiver(unsigned int & score = 10);
                                       ^
stdout
Standard output is empty