double in class?


Hel)lo!
Please, why is that program not outputting price (typ double )?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
      #include<iostream>
    using namespace std;
     
     
    class product {
     
    public:
    int ID;
    string name;
    string price;
    product(int, string, double);
    };
     
    product::product (int a, string b, double c) {
    ID = a;
    name = b;
    price=c;
    }
     
     
    int main(){
     
    /* product toy;
      product book;
      product dress;*/
     
    product toy (1, "Toy", 11.22);
    product book (2, "Book", 22.33);
    product dress (3, "Dress", 33.44);
     
    cout<<toy.ID<<endl<<toy.name<<endl<<toy.price<<endl<<endl<<book.ID<<endl<<book.name<<endl<<book.price<<endl<<endl<<dress.ID<<endl<<dress.name<<endl<<dress.price<<endl;
    return 0;
     
    }


And what is the ! on the end of output?
Last edited on
closed account (28poGNh0)
because you declare price as string ,change it to double and see
Topic archived. No new replies allowed.