【发布时间】:2014-11-16 16:05:52
【问题描述】:
将整数推入向量的语法是什么,在 Custothe 类中?
class Customer {
vector <int> loyalID;
}
int main {
Customer customer;
vector<Customer>customers;
customers.push_back(/*some integers to go into loyalID vector*/);
}
【问题讨论】:
-
customers是Customer的向量,而不是int的向量。您可以将Customers 推到它上面,而不是ints。您可以将ints 推送到customer.loyalID上(或者如果它不是私人的也可以)。再说一遍,你想做什么? -
@IgorTandetnik 为每个客户存储 uniqueID(比如客户拥有的会员卡),当我访问特定客户时,显示这些 uniqueID。