fork(48) download
  1. #include <iostream>
  2. #include <string>
  3. #include <vector>
  4.  
  5. int main()
  6. {
  7. const std::vector<std::string> Months {
  8. "January",
  9. "February",
  10. "March",
  11. "April",
  12. "May",
  13. "June",
  14. "July",
  15. "August",
  16. "September",
  17. "October",
  18. "November",
  19. "December"
  20. };
  21.  
  22. Months[3] = "Oh no!";
  23. std::cout << Months[3] << std::endl;
  24. }
  25.  
Compilation error #stdin compilation error #stdout 0s 3472KB
stdin
Standard input is empty
compilation info
prog.cpp: In function ‘int main()’:
prog.cpp:22:12: error: passing ‘const value_type {aka const std::basic_string<char>}’ as ‘this’ argument of ‘std::basic_string<_CharT, _Traits, _Alloc>& std::basic_string<_CharT, _Traits, _Alloc>::operator=(const _CharT*) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]’ discards qualifiers [-fpermissive]
  Months[3] = "Oh no!";
            ^
stdout
Standard output is empty