pointers - 需要帮助找出正确的语法来更新全局范围内的对象
问题描述
我有这个代码:
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++;
}
}
}
我正在尝试更改原始列表to_whom
,rented_code
但它没有更新。
为了以我需要的方式更改这些值,我需要什么语法?
解决方案
推荐阅读
- php - Laravel Eloquent 根据设定条件查询多条记录
- algorithm - k路合并的时间复杂度是多少?
- c# - 使用 Bootstrap 3 子菜单的 ActionLink 不起作用,没有调用 url
- css - 背景图片未加载
- sql - 连续对某行进行pandas列操作
- azure - 获取运行 azure 应用服务的当前插槽?
- tomcat - 为什么 `onAttach` 在 Tomcat 下运行两次,但在 Vaadin Flow 11 Web 应用程序中的 Jetty 下只运行一次?
- javascript - 提示后在纯 JS 中保持复选框状态
- javascript - 我需要如何定义用户?ReferenceError: 用户未定义 Steam 用户
- magento2 - 分层导航减慢我们的网站。我应该升级托管计划吗