Linked List and Accessing Elements of Nodes??

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • keclipse2525
    New Member
    • Jan 2008
    • 6

    Linked List and Accessing Elements of Nodes??

    I have a program that is set up like a bank database and I need to use linked list to write all the transactions into a file. Where would you implement the code to write the transactions to a file? It is set up with two .cpp files and a header file. The header contains a structure with the declaration of functions and the one .cpp is the main while the other .cpp contains all the functions operations. Would the code to write the file go in the main or just make it a function along with the other functions in the .cpp file? Any suggestions?? thanks
    -K
  • gpraghuram
    Recognized Expert Top Contributor
    • Mar 2007
    • 1275

    #2
    Originally posted by keclipse2525
    I have a program that is set up like a bank database and I need to use linked list to write all the transactions into a file. Where would you implement the code to write the transactions to a file? It is set up with two .cpp files and a header file. The header contains a structure with the declaration of functions and the one .cpp is the main while the other .cpp contains all the functions operations. Would the code to write the file go in the main or just make it a function along with the other functions in the .cpp file? Any suggestions?? thanks
    -K
    My idea would be writing a separate function to do the same.
    If you can add more info i can help you
    Raghuram

    Comment

    • keclipse2525
      New Member
      • Jan 2008
      • 6

      #3
      Originally posted by gpraghuram
      My idea would be writing a separate function to do the same.
      If you can add more info i can help you
      Raghuram

      What information do u need I can post some sections of code to help get a better understanding of what Im asking, if that helps my very general questions hahaha?? thanks

      -K

      Comment

      • weaknessforcats
        Recognized Expert Expert
        • Mar 2007
        • 9214

        #4
        The code to write to the file should be in it's own .cpp file and you should make a header to include elsewhere.

        The reason is you may need the file writing code in another program sometime and if you have buriend with main() you can't use it in another program without removing the main(). To do that you would need to make a copy and then be faced with maintaining multiple sets of the same code.

        Keep related code that has a probable chance of being reused in separate files.

        Comment

        Working...