Need help figuriing out correct syntax to update objects in global scope

人走茶凉 提交于 2019-12-11 16:48:30

问题


I have this code:

int do_transact(ifstream & inFile, list<shared_ptr<Bike>> bikelist, status s)
{
    int id, i = 0, size = bikelist.size();
    float days;
    string str, str2;
    char name[50];
    list<shared_ptr<Bike>>::iterator it = bikelist.begin();


    if (s == NO_STATUS) //performs rental
    {
        inFile >> id;
        inFile >> days;

        inFile >> str;
        inFile >> str2;
        strcpy_s(name, str.c_str());


        while (i < size)
        {
            if (id == (*it)->id_num) // rents bike
            {
                cout << "vvvvvv PERFORMING RENTAL vvvvvv" << endl << endl;
                cout << "The price of this rental will be: $" << (days)*((*it)->cost_per_day) << endl;
                strcpy_s((*it)->to_whom, name);
                (*it)->rented_code = RENTED;
                cout << "Thank you for your business!" << endl << endl;
                return 0;
            }

            i++;
            it++;
        }
    }
}

I am trying to change to_whom and rented_code in the original list, but it is not updating.

What is the syntax I need in order to change these values the way I need?

来源:https://stackoverflow.com/questions/50053869/need-help-figuriing-out-correct-syntax-to-update-objects-in-global-scope

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!