Thread: Really niggly, easy problem

  1. #1
    Registered User
    Join Date
    Apr 2002
    Posts
    25

    Really niggly, easy problem

    Code:
    void Application::DoAddPerson()
    {
    dMenu.getOption();
    string N1;
    string Nf;
    string A1=" ";
    string A2=" ";
    string A3=" ";
    string PC=" ";
    TDate D;
    char G;
    string T=" ";
    
    	cout<<"\nEnter First Name  :";
    	Get(N1, 10);
    	cout<<"\nEnter Second Name :";
    	Get(Nf, 20);
                    cout<<"\nEnter Address Line 1 :";
    	Get(A1, 20);
    	cout<<"\nEnter Address Line 2 :";
                    Get(A2, 20);
    	cout<<"\nEnter Address Line 3 :";
                    Get(A3, 20);
    	cout<<"\nEnter Postcode :";
                    Get(PC, 8);
    	cout<<"\nGet Tel No. :";
    	Get(T, 8);
    
    Person* newPerson;
    newPerson= new Person(N1,Nf,A1,A2,A3,PC,D,G,T);
      newPerson->Print();
    }
    
    
    
    void DoAddStock()
    {
    
    eMenu.getOption();
    string SN;
    string Dn;
    double CS;
    float US;
    float UP;
    double MS;
    
    	cout<<"\nEnter Stock Number : ";
    	Get(SN, 8);
    	cout<<"\nEnter a Description of the Product : ";
    	Get(Dn, 30);
    	cout<<"\nEnter Initial Stock Level : ";
    	Get(CS, 6);
    	cout<<"\nEnter Unit Size : ";
    	Get(US, 6);
    	cout<<"\nEnter Unit Price : ";
    	Get(UP, 6);
    	cout<<"\nEnter Minimum Stock Level :";
    	Get(MS, 6) ;
    
    Stock* newStock;
    newStock= new Stock(SN,Dn,CS,US,UP,MS);
    newStock->Print();
    }
    The Get() function works on DoAddPerson() but on DoAddStock() it will not, it says its a call to an undefined function.

    Both of these functions are in the same CPP file.

    Any ideas why this is happening.

    And i have included <iostream.h>, because it works on the one but not the other.

  2. #2
    Registered User
    Join Date
    Jun 2002
    Posts
    82
    It would probably help if you posted the code for the Get() function as well.
    Claus Hetzer
    Compiler: Borland 5.5 (on Windows)
    Solaris CC (on Unix)
    Known Languages: C++, MATLAB, Perl, Java

  3. #3
    Cheesy Poofs! PJYelton's Avatar
    Join Date
    Sep 2002
    Location
    Boulder
    Posts
    1,728
    Also, are the two function definitions you wrote down listed back to back like that in your program, or are they separated, possibly in different files? And where in relation to the two of these is Get defined?

  4. #4
    Registered User
    Join Date
    Apr 2002
    Posts
    25
    Get() is part of the <iostream.h> header and hence is not my work and the functions are in the same file, back to back.

  5. #5
    Senior Member joshdick's Avatar
    Join Date
    Nov 2002
    Location
    Phildelphia, PA
    Posts
    1,146
    Originally posted by Ryan_P
    Get() is part of the <iostream.h> header and hence is not my work and the functions are in the same file, back to back.
    I think what you want to use is
    Code:
    get();
    // NOT
    Get();
    I think that capitalizing the G is what's causing your problem.
    FAQ

    "The computer programmer is a creator of universes for which he alone is responsible. Universes of virtually unlimited complexity can be created in the form of computer programs." -- Joseph Weizenbaum.

    "If you cannot grok the overall structure of a program while taking a shower, you are not ready to code it." -- Richard Pattis.

  6. #6
    Registered User
    Join Date
    Apr 2002
    Posts
    25
    Cheers everyone.

    It turns out that it was because i didn't make DoAddStock() part of the Application class.

    I am having more trouble now with another problem, but ill start a new thread for that one.....

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 5
    Last Post: 11-07-2005, 11:34 PM
  2. Relatively easy math problem...
    By gcn_zelda in forum A Brief History of Cprogramming.com
    Replies: 6
    Last Post: 10-18-2005, 08:48 PM
  3. searching problem
    By DaMenge in forum C Programming
    Replies: 9
    Last Post: 09-12-2005, 01:04 AM
  4. Math Problem....
    By NANO in forum A Brief History of Cprogramming.com
    Replies: 18
    Last Post: 11-11-2002, 04:37 AM
  5. half ADT (nested struct) problem...
    By CyC|OpS in forum C Programming
    Replies: 1
    Last Post: 10-26-2002, 08:37 AM