linked list an objects

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
do I need a copy oopy constructor?

class book{
    
      string title

      string author[4];
}

class Sale{

     Book book;
     float totalsoldprice;
}

struct salesRecorc{
    Sale sale
    salesRecord* next;

};

main(){

   Book book[2];

   //initialise book
   //choose book to sell

    Sale sale(book)//Do i do this as copy or normal initialisation?
     salesRecord* head=Null
     head->sale=sale;//do I need copy constructor to do this also? 




}
You don't need a copy constructor for book or Sale. They are automatically generated.

Copying salesRecorc (typo?) would be a problem.

If you want something like on line 29 you need a constructor that takes book as parameter. Note that Sale takes only a single book not an array.
Topic archived. No new replies allowed.