Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Loop for instream from file
- ifstream furniture;
- furniture.open("h://furniture.txt");
- for(int i=0;i<=count;i++)
- {
- type=0;
- furniture>>type>>name>>number>>material>>colour>>mattress;
- switch (type)
- {
- case 1:
- {
- Item* item= new Bed(number, name, material, colour, mattress);
- cout<<"working, new bed"<<endl;
- v.push_back(item);
- cout<<"working pushback"<<endl;
- count++;
- break;
- }
- case 2:
- {
- Item* item= new Sofa(number, name, material, colour);
- cout<<"working, new sofa"<<endl;
- v.push_back (item);
- cout<<"working pushback"<<endl;
- count++;
- break;
- }
- case 3:
- {
- Item* item= new Table(number, name, material, colour);
- cout<<"working, new table"<<endl;
- v.push_back(item);
- cout<<"working pushback"<<endl;
- count++;
- break;
- }
- default:
- {
- cout<<"Invalid input"<<endl;
- type=0;
- break;
- }
- }
- }
- string line;
- getline(furniture, line);
- stringstream ss(line);
- ss>>type>>name>>number>>material>>colour>>mattress;
Add Comment
Please, Sign In to add comment