Recursive function gives undefined reference bug

This is a discussion on Recursive function gives undefined reference bug within the C++ Programming forums, part of the General Programming Boards category; The following section of my code is giving me problems (cout statements removed to save space): Code: int CSP; void ...

  1. #1
    Registered User
    Join Date
    Dec 2010
    Posts
    1

    Recursive function gives undefined reference bug

    The following section of my code is giving me problems (cout statements removed to save space):

    Code:
      int CSP;
      void allocatecsp (); {
      cin >> CSP;
      cin >> sws;
      CSP = CSP - sws;
      cin >> axs;
      CSP = CSP - axs;
      cin >> sps;
      CSP = CSP - sps;
      cin >> bos;
      CSP = CSP - bos;
      cin >> shs;
      CSP = CSP - shs;
      int cspreallocate;
      if (CSP > 0) {
            cin >> cspreallocate;
            if (cspreallocate = 0) {
                allocatecsp ();     //  ********************
            }
      }
      else if (CSP < 0) {
           allocatecsp ();  // ********************
      }
      else {
            cin >> cspreallocate;
            if (cspreallocate == 0) {
            allocatecsp (); // ********************
            }
        }
      }
    When I try to compile, it returns "undefined reference to 'allocatecsp()'" error in the lines marked with stars. Any idea why this would be (all variables not declared here are declared above the top)?

  2. #2
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    22,302
    This:
    Code:
    void allocatecsp (); {
    should be:
    Code:
    void allocatecsp () {
    This line looks like it has another mistake:
    Code:
    if (cspreallocate = 0) {
    Furthermore, avoid the use of global variables, and although you made a good attempt at indentation, it could still be improved.
    C + C++ Compiler: MinGW port of GCC
    Version Control System: Bazaar

    Look up a C++ Reference and learn How To Ask Questions The Smart Way

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Undefined Reference to functions, that CAN be found
    By Carola in forum C++ Programming
    Replies: 8
    Last Post: 08-27-2009, 06:59 AM
  2. undefined reference to function names
    By hellogamesmaste in forum C Programming
    Replies: 5
    Last Post: 08-17-2009, 04:05 AM
  3. Dikumud
    By maxorator in forum C++ Programming
    Replies: 1
    Last Post: 10-01-2005, 07:39 AM
  4. Textbox
    By maxorator in forum Windows Programming
    Replies: 20
    Last Post: 09-25-2005, 11:04 AM
  5. Interface Question
    By smog890 in forum C Programming
    Replies: 11
    Last Post: 06-03-2002, 06:06 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21