fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. namespace pers
  5. {
  6. using std::cout;
  7. using std::cin;
  8. int x = 5;
  9.  
  10. struct Person
  11. {
  12. std::string fname;
  13. std::string lname;
  14. };
  15.  
  16. void getPerson(Person & rp)
  17. {
  18. cout << "Enter first name: ";
  19. cin >> rp.fname;
  20. cout << "Enter last name: ";
  21. cin >> rp.lname;
  22. }
  23. }
  24.  
  25. namespace debts
  26. {
  27. struct Debt
  28. {
  29. pers::Person name;
  30. double amount;
  31. };
  32.  
  33. void getDebt(Debt & rd)
  34. {
  35. getPerson(rd.name);
  36. std::cout << "Enter debt: ";
  37. std::cin >> rd.amount;
  38. cout << x << endl;
  39. }
  40. }
  41.  
  42. int main() {
  43. // your code goes here
  44. return 0;
  45. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp: In function 'void debts::getDebt(debts::Debt&)':
prog.cpp:38:17: error: 'x' was not declared in this scope
         cout << x << endl;
                 ^
prog.cpp:38:17: note: suggested alternative:
prog.cpp:8:9: note:   'pers::x'
     int x = 5;
         ^
stdout
Standard output is empty