fork download
  1. #include <iostream>
  2. #include <string>
  3. #include <array>
  4.  
  5. using namespace std;
  6.  
  7. const int Seasons = 4;
  8. const std::array<string, Seasons> Snames =
  9. {"spring", "summer", "fall", "winter"};
  10.  
  11. void fill(array<double, Seasons>* pa);
  12. void show(array<double, Seasons> da);
  13.  
  14. int main()
  15. {
  16. std::array<double, Seasons> expenses;
  17. fill(&expenses);
  18. show(expenses);
  19.  
  20. return 0;
  21. }
  22.  
  23. void fill(array<double, Seasons>* pa)
  24. {
  25. for(int i = 0; i < Seasons; i++)
  26. {
  27. cout << "Enter " << Snames[i] << " expenses: ";
  28. cin >> *pa[i];
  29. }
  30. }
  31.  
  32. void show(array<double, Seasons> da)
  33. {
  34. double total = 0.0;
  35. cout << "\nEXPENSES\n";
  36.  
  37. for(int i = 0; i < Seasons; i++)
  38. {
  39. cout << Snames[i] << ": $" << da[i] << endl;
  40. total += da[i];
  41. }
  42. cout << "Total Expenses: $" << total << endl;
  43. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp: In function 'void fill(std::array<double, 4u>*)':
prog.cpp:28:17: error: no match for 'operator*' in '**(pa + ((unsigned int)(((unsigned int)i) * 32u)))'
stdout
Standard output is empty