samedi 26 janvier 2019

cannot bind non-const lvalue reference of type to an rvalue of type

void Create_moneys(shared_ptr<CoinMoney>* &ms){
    int max = getSize(true);
    for(size_t i = 0; i < max; ++i){
        cout << "ms is : " <<typeid(ms[i]).name() << endl;
        ms[i] = make_shared<CoinMoney>();
        ms[i]->c50 = i+1;
        ms[i]->c100 = i+2;
        ms[i]->c500 = i+3;
    }
}

int main(int argc, char* argv[]){
    shared_ptr<CoinMoney> pm1[getSize(true)];
    Create_moneys(pm1); // error
    for(auto p : pm1)
        CoinMoney_Print(*p);
    return 0;
}

I'm getting this error "cannot bind non-const lvalue reference of type ~ to an rvalue of type

I don't understand this error plz :(

Aucun commentaire:

Enregistrer un commentaire