Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C++
I have a program that is creating a journal and creating a class and moving that class to a global linked list.. Each entry is the same class with different elements.. such that one element is int bookEntry and one is double bookPages.. How do I add the bookPages that are contained in each list as the program grows.
Ok.. I did not word this the best.. I have a class called bookInventory.. this class is comprised of different variables that are storing information into several different list of the same class.. so I need to be able to add up all the elements of bookPages of all the different linked lists in my program and keep a total of them as each new entry (linked list) is added
Posted 12-May-13 15:04pm
Edited 13-May-13 16:23pm
v2
Comments
AYDIN EBRAHIMI HOMAY at 12-May-13 23:56pm
   
I cant understand your question what you want do that please explain more.
CPallini at 13-May-13 4:59am
   
"Each entry is the same class with different elements"
Do you mean different objects of the same class?
"such that one element is int bookEntry and one is double bookPages"
This is obscure to me.
Please elaborate.
H.Brydon at 13-May-13 21:43pm
   
This seems to be a duplicate. Either this or the other one should be deleted perhaps?

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

Hi Gavon,
 
I guess you are using a static structure.
 
You should use a dynamic 'templated' structure such as the std list. You can control the list with the 'push' and 'pop' methods...
 
I hope it helps.
 
Cheers,
Yass.
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 386
1 Marcin Kozub 225
2 Sergey Alexandrovich Kryukov 215
3 /\jmot 189
4 Praneet Nadkar 173
0 OriginalGriff 8,289
1 Sergey Alexandrovich Kryukov 7,407
2 DamithSL 5,624
3 Maciej Los 4,989
4 Manas Bhardwaj 4,986


Advertise | Privacy | Mobile
Web02 | 2.8.1411023.1 | Last Updated 13 May 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100