Click here to Skip to main content
15,846,009 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Im trying to create a productlist class and i want get a another class seller who insert seller id and name.. and Insert Product list of seller.

this is a simple what that i mean but this with a library

C++
cout << " ENTER CONTACT OF SELLER  : " << endl;
cin >> contact;

//INSERT PRODUCT LIST OF SELLER
int choice = 1;
Product p;
while (choice == 1)
{
cout<<  "ENTER YOUR PRODUCT DETAILS \n" << endl;
p.insert();
pl.push_back(p);
cout << " IF YOU WANT TO ENTER MORE PRODUCTS PRESS 1 ELSE PRESS 0 \n";
cin >> choice;
}

and that what im doing
C++
    cout << " Contact :" << endl;
    cin >> C_contact;
    St.setID(C_ID);
    St.setname(C_na);
    St.setrating(C_rating);
    St.setcontact(C_contact);

    Seller_Node* temp = new Seller_Node;
    temp->data = St;
    temp->next = head;
    head = temp;
    cout << "\nSuccessfully Inserted..!\n\n";
}


What I have tried:

i want to add product::inset here but i dont know how
Posted
Updated 18-Jan-23 14:21pm
v2

1 solution

Since all the class definitions are missing, I added the references to them.
The chained list indicates that multiple sellers are intended.
The product data are then probably simple member variables that can be read in and assigned.
C++
bool Product::insert()
{
    class Seller_Data St;
    
    // ...

	// Insert Seller data
	Seller_Node* temp = new Seller_Node;
    temp->data = St;
    temp->next = head;
    head = temp;
    cout << "\nSeller successfully Inserted..!\n\n";

	// TODO: Insert Product data
	
	return true;
}

Note: I'm a bit puzzled that the sellers are tediously managed with a self-created chained list, while the products are obviously comfortably managed in an STD container. Sellers should also be managed in an STD container.
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900