mercredi 30 décembre 2015

std vector at could not resolve on eclipse

I have this code in eclipse:

#include <vector>

typedef struct tal{
    tal()
    :a(0), b(0)
    {};
    int a;
    int b;
} Tal;

int main() {
    std::vector<Tal> tal_vec;
    Tal tt;
    tal_vec.push_back(tt);
    Tal tt2 = tal_vec.at(0);
    tt2.a;

    int c = tal_vec.at(0).a;
}

At the last statement: int c = tal_vec.at(0).a;
Eclipse tell me: Field 'a' could not be resolved.

Already tell CDT GCC Builtin Compiler add this: -std=c++11 flag like here

In the other statement you can see that there is no error if i tell eclipse to go Tal tt2 = tal_vec.at(0); the after that to get filed a value.

can anyone suggest a solution?

Aucun commentaire:

Enregistrer un commentaire