what am i doing wrong

closed account (1vf9z8AR)
The value of price and number of items comes to be 0 when reading file.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
 class cart
{
private:
        char items[80];
         int no=0;
        float price=0;
public:
        void getdata()
        {
               category(items,no,price);
               ofstream w1;
               w1.open("file.dat");
               w1<<"Total price="<<price<<"\n";
               w1<<"Total items="<<no<<"\n";
                w1.close();
        }
        void outdata()
        {
                cout<<"\n\nProceeding to checkout"<<endl;
        }
};
Last edited on
we can't see anything.
price is set to zero. no is set to zero. If you write them out, you will get 0 and 0. If you changed these values, we can't see this.


Topic archived. No new replies allowed.