简体   繁体   中英

how can i make a pointing to const int inside a string vector?

im trying to make a program where costumers info gets stored struct, and pointers. but i cant get a vector to point to a const value.

struct costumer{ 
   string name;
   string email_adress;
   int *subscription ????
}

i can add the costumer name, and email_adress but im trying to have the struct store the sold subscribtion. so for example someone bought a yearly subscription of television for const $100 a year. I add subscribtion then television then 100 it should display television(100). costumer can have multiple subscriptions stored in a vector. so subscriptions = {television(100), internet(50),...,netflix(20)}. so if ask to see what subscriptions a costumer has. it displays these. if im not really clear sorry english is not y first language.

Subscriptions should have information of both what he subscribed to and cost. int* is not sufficient to store both. one of the possible solutions may be creating subscription structure.

typedef struct subscription{
 string subscribed_to;
 int    cost;
 }subscription;

struct customer{
 string name;
 string email_id;
 int num_of_subscriptions;
 subscription subs[20];
};

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM