lundi 29 mai 2017

C++ std::vector

#include <iostream>
#include <vector>

int main() {

    std::vector<int> A[4];
    A[3].push_back(1);
    A[3].push_back(7);
    for(int i = 0; i < A[3].size(); i++){
        std::cout << A[3][i] << std::endl;
    }
    std::cout << std::endl;

    return 0;
}

How does the [] affect std::vector - how is it different from std::vector<int>(4); ? Can't find any documentation. std::vector<int>A[4] later behaves as a 2d vector. Why?

Aucun commentaire:

Enregistrer un commentaire