I am trying to initialize a vector member variable with an array of integers:
#include <vector>
#include <iostream>
struct A
{
A(int arr[]) : mvec(arr)
{
}
std::vector<int> mvec;
};
int main()
{
A s({1,2,3});
}
Compilation gives me error :
$ c++ -std=c++11 try59.cpp
try59.cpp:15:12: note: candidates are:
try59.cpp:6:1: note: A::A(int*)
A(int arr[]) : mvec(arr)
How can I initialize my vector using an array of integers?
Aucun commentaire:
Enregistrer un commentaire