Go Back   PCMech Forums > Help & Discussion > Web Design / Development

Need Some Help? Type Your Keywords Here:

Reply
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
Old 02-14-2005, 08:27 PM   #1
Member (7 bit)
 
Join Date: Nov 2003
Location: LA
Posts: 101
Send a message via AIM to HNPFL
C++ Function by Refrence (Passing Parameters by reference)

I have an issue concerning passing variables by reference. I have some code for you C++ experts to look at. I have seemed to narrow down all the conventional errors and I am left with only 2 of them. The first is:

Code:
 839 error LNK2019: unresolved external symbol "void __cdecl getMinutes(void)" (?getMinutes@@YAXXZ) referenced in function _main
and the second is:

Code:
839 fatal error LNK1120: 1 unresolved externals
The assignment is to do some calculations of hours and minuets but I just need to be able to pass variables first. And the error only occurs when I call the "getMinuets" function, but I have the "getHours" function working fine.

heres the full code:
Code:
#include 
#include 
#include 

using namespace std;

// prototype functions

void getHours (int &bhours, string);
void getMinutes (); //int &bmin, string
//void calcTotalTime (int &thours, int &gmin, int &ghours, int &tmin);
//bool isValidMinutes ();
//bool isValidHours();

int main()
{

       //Declare Vars
//       int shours, smin, ehours, emin, hours, minuets;
	int shours = 0;
	int smin = 0;

       /////////////////////////////////////// Call Functions / get input

     getHours(shours, "Enter Start Hours: ");
     getMinutes(); // smin, "Enter Start Minutes: "

//   getHours (ehours, "Enter End Hours: ");
       //getMinutes (emin,  "Enter End Minuets: ");
   //calcTotalTime (shours, smin, ehours, emin);

       //output
//      cout << "The total time is " << hours << " hours and " << minuets << " minutes." << endl;

system("pause");
return 0;
}

void getHours(int &shours, string display)
{
       bool validinput = false;
   int starthours;

      do
      {
            cout << display ;
            cin >> starthours ;

                        if (!(starthours > 0 && starthours < 24 )){

                   cout << "Hours must be at least 0, and no more than 23" << endl ;

                        }else{
                   validinput = true ;
                        }

          } while (validinput == false) ;

}

void getMinuets() //int &smin, string display
{
/*
       bool validinput = false;
       int startminuets;

      do
      {
            cout << display;
            cin >> startminuets;

                        if (!(startminuets > 0 && startminuets < 24 )){

							cout << "Minuets must be at least 0, and no more than 23" << endl ;

                        }else{

							validinput = true ;
                        }

        } while (validinput == false) ;
*/

}

void calcTotalTime(int &shours, int &smin, int &ehours, int &emin)
{

}
HNPFL is offline   Reply With Quote
Old 02-14-2005, 09:35 PM   #2
Member (10 bit)
 
Join Date: Jul 2002
Location: University of California, Santa Barbara
Posts: 800
In the function prototypes you spell it "getMinutes", but when you define it you misspell it as "getMinuets".

Also, there is no reason that I can use to pass variables by reference, I would use a return statement to make the code read a bit easier.

And just a suggestion, if you are going to have a display string in the parameters of those "get" functions, you could generalize even further and add a minimum and maximum input range and have a generic "int getInteger(string prompt, int min, int max)", or something like that.

Last edited by mattg2k4; 02-14-2005 at 09:39 PM.
mattg2k4 is offline   Reply With Quote
Old 02-15-2005, 04:02 PM   #3
Member (7 bit)
 
Join Date: Nov 2003
Location: LA
Posts: 101
Send a message via AIM to HNPFL
I feel like a moron

I'm embarrassed.. Thanks for replying to my post. I'm doing my project like this because it is an assignment to use pass by refrence. Thank you very much.

Last edited by HNPFL; 02-15-2005 at 04:04 PM. Reason: improper grammer
HNPFL is offline   Reply With Quote
Reply

Bookmarks

Still Need Help? Type Your Keywords Here:


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -5. The time now is 07:17 AM.
Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2012, vBulletin Solutions, Inc.
SEO by vBSEO 3.6.0 PL2