实例 C++ 修改数组中的元素

x
 
#include <iostream>
#include <string>
using namespace std;
int main() {
  string cars[4] = {"Volvo", "BMW", "Ford", "Mazda"};
  cars[0] = "Opel";
  cout << cars[0];
  return 0;
}
                    

输出结果

Opel