Delegating to a linked issue

Jan 31, 2017 at 9:17am
Hi I am doing a chapter in my book about delegating to a linked list. When I compile the example in the book :

http://pastebin.com/Ahe8XMb1
http://pastebin.com/xD7UBJtZ

I get : ./headerfile.hpp: In member function 'void PartsCatalog::ShowAll()':
./headerfile.hpp:97:47: error: invalid use of non-static member function 'virtual void Part::Display() const'
void ShowAll() { thePartsList.Iterate(Part::Display); }

So I followed the compliers advice and used static functions instead.

http://pastebin.com/3MKiXHV0
http://pastebin.com/aCL7uR2u

I managed to get the program going but at the end it is supposed to put out the model numbers and model years i.e.

Part Number: 1234
Model Year: 94

Part Number: 2345
Model Year: 93

Part Number: 4434
Model Year: 93

But I get:

(0)Quit (1)Car (2)Plane:
Current Part No: 1
1
New part Number?: 1234
ModelYear?:94
(0)Quit (1)Car (2)Plane:
Current Part No: 1
1
New part Number?: 4434
ModelYear?:93
(0)Quit (1)Car (2)Plane:
Current Part No: 1
1
New part Number?: 1234
ModelYear?:94
1234 was the first entry. Rejected!
(0)Quit (1)Car (2)Plane:
Current Part No: 1
1
New part Number?: 2345
ModelYear?:93
(0)Quit (1)Car (2)Plane:
Current Part No: 1
0

Part Number: 1
Press ENTER to continue...


The part number is not even changing in the class even though the program is able to say it has been repeated.

Please can someone help me fix this, I've tried to make sure my declarations are the same as my definitions and I've followed the compilers advice, tried changing storage types, including return types and moving round * and & but nothings working. Thanks.

Jan 31, 2017 at 11:26pm
Change this line
void ShowAll() { thePartsList.Iterate(Part::Display)
To
void ShowAll() { thePartsList.Iterate(&Part::Display)

This annoying inconsistency is required only for member functions.
Last edited on Jan 31, 2017 at 11:27pm
Feb 4, 2017 at 10:36am
Hi I already did that in http://pastebin.com/aCL7uR2u to get it running but the output is not as expected so what is the next step?
Topic archived. No new replies allowed.