call to undefined function...

This is a discussion on call to undefined function... within the C++ Programming forums, part of the General Programming Boards category; how come it cant find it... This is select.h with the menu function: Code: #ifndef _SELECT_H #define _SELECT_H #include "center.h" ...

  1. #1
    Registered User
    Join Date
    Sep 2002
    Posts
    72

    call to undefined function...

    how come it cant find it...

    This is select.h with the menu function:

    Code:
    #ifndef _SELECT_H
    #define _SELECT_H
    
    #include "center.h"
    #include "choice.h"
    
    
    void menu(double winning_amount, double total,double &nettotal)
    {
       int ch;
       time_t t=time(NULL);
       cout <<ctime(&t) << endl;
       cout << endl;
    	center("Shopping Spree Program",3);
       center("~~~~~~~~~~~~~~~~~~~~~~",4);
       cout << endl;
       cout << "a.\tComputer Shop" << endl;
       cout << "b.\tTotal" << endl;
       cout << "c.\tQuit" << endl;
     	for(/*forever*/;((ch = getch()) != EOF);)
       switch(ch)
       {
       case 'a' :
       	choicecomp(winning_amount,total,nettotal);
       	break;
       default :
       	cout << "Bye Bye" << endl;
          getch();
          break;
       }
    
    }
    
    #endif
    It says the error in the following section, this is choice.h:

    Code:
    
    
    #ifndef _CHOICE_H
    #define _CHOICE_H
    
    #include "select.h"
    #include <iostream.h>
    #include <conio.h>
    #include "center.h"
    #include <time.h>
    
    
    void choicecomp(double winning_amount, double total,double &nettotal)
    {
       double CompChoice;
       do
       {
    
    	time_t t=time(NULL);
       center("Shopping Paradise - Winner's Circle",3);
       center("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~",4);
       cout <<" 1.\tHard Drive" << endl;
       cout <<" 2.\tFloppy Disk" << endl;
       cout <<" 3.\tCD Burner " << endl;
       cout <<" 4.\tBlank CDs " << endl;
       cout <<" 5.\tMonitor " << endl;
       cout <<" 6.\tSpeakers" << endl;
       cout <<" 7.\tVideo Card" << endl;
       cout <<" 8.\tGlass Case" << endl;
       cout <<" 9.\tWireless Keyboard" << endl;
       cout <<"10.\tWireless Mouse " << endl;
       cout <<"11.\tComputer Table " << endl;
       cout <<"12.\tWindows XP Home " << endl;
       cout <<"13.\tMotherboard " << endl;
       cout <<"14.\tRogers @Home Starter Kit " << endl;
       cout <<"15.\tMicrosoft Works XP" << endl;
       cout <<"16.\tBorland C++ v. 6.0" << endl;
       cout <<"17.\tRouter" << endl;
       cout <<"18.\tNetwork Hub + Ethernet Card" << endl;
       cout << endl;
       cout <<"What is your choice : ";
       cin >> CompChoice;
       if(CompChoice == 19)
                 menu(winning_amount,total,nettotal);  <-- It cant find
       if(CompChoice == 1)
         	total = total - 50;
       else if(CompChoice == 2)
         	total = total - 5;
       else if(CompChoice == 3)
         	total = total - 100;
       else if(CompChoice == 4)
         	total = total - 10;
       else if(CompChoice == 5)
         	total = total - 40;
       else if(CompChoice == 6)
         	total = total - 90;
       else if(CompChoice == 7)
         	total = total - 80;
       else if(CompChoice == 8)
         	total = total - 130;
       else if(CompChoice == 9)
         	total = total - 20;
       else if(CompChoice == 10)
         	total = total - 25;
       else if(CompChoice == 11)
         	total = total - 175;
       else if(CompChoice == 12)
         	total = total - 200;
       else if(CompChoice == 13)
         	total = total - 10;
       else if(CompChoice == 14)
         	total = total - 15;
       else if(CompChoice == 15)
         	total = total - 30;
       else if(CompChoice == 16)
         	total = total - 21;
       else if(CompChoice == 17)
         	total = total - 19;
       else if(CompChoice == 18)
         	total = total - 82;
       else
          	cout << "Sorry, That is an Invalid Selection..." << endl;
    	clrscr();
    
       cout<<total;
       }
    	while(total > 0);
    
       total = nettotal;
    
    
    
    }
    
    #endif
    I dont understand why it doesn't work... any help would GREATLY be appreciated

  2. #2
    i want wookie cookies the Wookie's Avatar
    Join Date
    Oct 2002
    Posts
    455
    You need to specify a function prototype for each function

  3. #3
    Registered User
    Join Date
    Sep 2002
    Posts
    72
    the other ones work without prototypes...

    i dont know what prototypes are so could someone write one where i need it for the libraries i have posted please.

  4. #4
    Registered User
    Join Date
    Apr 2002
    Posts
    362
    This is as obscure as you can get, but how did 'menu()' get by the compiler when using 'getch()' requires <conio.h>?

    Offhand, I'd say that's the only inconsistency that I can spot in the code you've provided.

    Addendum: This would serve as a 'prototype':

    void menu(double, double, double&);

    (Having said that, I've seen code that will not execute without including variable names with the prototype, i.e. 'void menu(double x, double y, double& z);'. The variables don't have to match what you pass to the function, but must be included in the prototype (declaration).)

    -Skipper
    "When the only tool you own is a hammer, every problem begins to resemble a nail." Abraham Maslow

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Compiling sample DarkGDK Program
    By Phyxashun in forum Game Programming
    Replies: 6
    Last Post: 01-27-2009, 02:07 AM
  2. Help calling function is asm
    By brietje698 in forum C++ Programming
    Replies: 24
    Last Post: 12-06-2007, 03:48 PM
  3. Troubleshooting Input Function
    By SiliconHobo in forum C Programming
    Replies: 14
    Last Post: 12-05-2007, 06:18 AM
  4. Question about OpenGL/Linux
    By Ideswa in forum Linux Programming
    Replies: 12
    Last Post: 09-10-2006, 05:56 AM
  5. Interface Question
    By smog890 in forum C Programming
    Replies: 11
    Last Post: 06-03-2002, 05:06 PM

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