Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- struct Product
- {
- char description[32];
- int part_num;
- double cost;
- void create(char description_[], int num_, double cost_)
- {
- for(int i = 0; description_[i] != '\0'; i++)
- {
- description[i] = description_[i];
- }
- part_num = num_;
- cost = cost_;
- }
- void print_descr(Product p1)
- {
- cout << p1.description << endl;
- }
- void print_num(Product p1)
- {
- cout << p1.part_num << endl;
- }
- void print_cost(Product p1)
- {
- cout << p1.cost << endl;
- }
- };
- int main()
- {
- Product p1;
- Product p2;
- p1.create("headphones", 12095, 100);
- p2.create("microphone", 10294, 499);
- p1.print_descr(p1);
- p2.print_cost(p2);
- return 0;
- }
Add Comment
Please, Sign In to add comment