W3School TIY Editor

  • W3School 在线教程
  • 改变方向
  • 暗黑模式
​x
 
#include <iostream>
#include <vector>
using namespace std;
​
int main() {
  // 创建存储字符串的向量 cars 
  vector<string> cars = {"Volvo", "BMW", "Ford", "Tesla"};
​
  // 创建向量迭代器 it 
  vector<string>::iterator it;
​
  // 指向最后一个元素 
  it = cars.end() - 1;
​
  // 输出最后一个元素 
  cout << *it;
  
  return 0;
}