Thread: multiple file use

  1. #16
    Registered User
    Join Date
    Oct 2001
    Posts
    224
    ok here is the file with the fuction.... it is 317 lines (one function ) i could probably break it up too.
    Last edited by c++.prog.newbie; 02-12-2005 at 07:48 PM.

  2. #17
    Handy Andy andyhunter's Avatar
    Join Date
    Dec 2004
    Posts
    540
    Are you kidding me? You really want someone to go through all that.

    Try adding a left brace at the end of the function.
    i don't think most standard compilers support programmers with more than 4 red boxes - Misplaced

    It is my sacred duity to stand in the path of the flood of ignorance and blatant stupidity... - quzah

    Such pointless tricks ceased to be interesting or useful when we came down from the trees and started using higher level languages. - Salem

  3. #18
    Registered User
    Join Date
    Feb 2005
    Posts
    14
    Can't work it out - the main problem is the length of your function
    Each function should have one logical purpose
    so instead have something like:

    Code:
     
    void startSelection1()
    {
         char ch = printMenu1();
         switch(ch)
         {
              case 'g':
                 // do something
                 // e.g startSelection2
              case 'f'
                 // do something else
          }
    }
    
    char printMenu1()
    {
          char t;
          // print out first menu 
          // get input from user
          return t;
    }
    
    //then for further menus do something similar;
    Splitting this up will make it readable and more logical.
    (and help you find errors!)

  4. #19
    Registered User
    Join Date
    Oct 2001
    Posts
    224
    fine ill do something senseable and split it up into smaller functions

  5. #20
    Handy Andy andyhunter's Avatar
    Join Date
    Dec 2004
    Posts
    540
    Try adding a left brace at the end of the function.
    I'm serious its missing a closing bracket, oops I meant right brace.
    i don't think most standard compilers support programmers with more than 4 red boxes - Misplaced

    It is my sacred duity to stand in the path of the flood of ignorance and blatant stupidity... - quzah

    Such pointless tricks ceased to be interesting or useful when we came down from the trees and started using higher level languages. - Salem

  6. #21
    Registered User
    Join Date
    Oct 2001
    Posts
    224
    Believe it or not i split the function up and guess what!!!! i found the problem !!!! but im not too sure what it was( i think you were right with the closing bracket)

    but now I get this

    [code]
    main.cpp C:\arg\main.o(.bss+0x0) multiple definition of `spells_b'
    [\code]

    i get this error because im declaring struct spells_b in the header because i need it in both .cpp's which brings me back to one of my previous questions... were do i put variable that i need in both .cpp's??

    thx for all the help guys(and gals )

  7. #22
    Handy Andy andyhunter's Avatar
    Join Date
    Dec 2004
    Posts
    540
    Place it in one header file and be sure to include the header file in all the files that need it.
    i don't think most standard compilers support programmers with more than 4 red boxes - Misplaced

    It is my sacred duity to stand in the path of the flood of ignorance and blatant stupidity... - quzah

    Such pointless tricks ceased to be interesting or useful when we came down from the trees and started using higher level languages. - Salem

  8. #23
    Registered User
    Join Date
    Oct 2001
    Posts
    224
    i have the variables in one file. and the files that need it link to that file (#include "blah.h") but it says its declared first in blah.h then in main.cpp i look all through main and nothing declaring.

  9. #24
    Handy Andy andyhunter's Avatar
    Join Date
    Dec 2004
    Posts
    540
    I think you need to reread the FAQ
    i don't think most standard compilers support programmers with more than 4 red boxes - Misplaced

    It is my sacred duity to stand in the path of the flood of ignorance and blatant stupidity... - quzah

    Such pointless tricks ceased to be interesting or useful when we came down from the trees and started using higher level languages. - Salem

  10. #25
    Registered User
    Join Date
    Oct 2001
    Posts
    224
    i read, reread, and rereread the FAQ's but i didnt see anything about were to declare variables globaly that will be in both .cpp's unless the answer is just staring me in the face and im looking past it.

    EDIT:
    It is my sacred duity to stand in the path of the flood of ignorance and blatant stupidity... - quzah
    ^ me right now
    Last edited by c++.prog.newbie; 02-12-2005 at 07:26 PM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. A development process
    By Noir in forum C Programming
    Replies: 37
    Last Post: 07-10-2011, 10:39 PM
  2. Formatting a text file...
    By dagorsul in forum C Programming
    Replies: 12
    Last Post: 05-02-2008, 03:53 AM
  3. help with text input
    By Alphawaves in forum C Programming
    Replies: 8
    Last Post: 04-08-2007, 04:54 PM
  4. C++ std routines
    By siavoshkc in forum C++ Programming
    Replies: 33
    Last Post: 07-28-2006, 12:13 AM
  5. what does this mean to you?
    By pkananen in forum C++ Programming
    Replies: 8
    Last Post: 02-04-2002, 03:58 PM