   Me vs. VC++ Express Edition 8 : Round 5
  Hello,I have been working on a little basketball game, and I cannot understand the error VC++ Express Edition is giving me. A plethora of people have said that the debugger was so good, but I dont get why! Below is my source code along with the errors its giving me.Someone PLEASE Help me! Im pretty sure its something dumb of me. [sad]Source:#include "stdafx.h"#include <ctime>#include <string>#include <iostream>#include <vector>#include <algorithm>std::string teamSelection();std::string compSelection();int playerShoot(int &pScore, std::string pTeam);int computerShoot(int &cScore, std::string cTeam);void welcome();void printScore(int &pScore, int &cScore, std::string cTeam, std::string pTeam);void winMessage(int &pScore, int &cScore, std::string cTeam, std::string pTeam);void loseMessage(int &pScore, int &cScore, std::string cTeam, std::string pTeam);int main(){srand(time(0));int playersShot,computersShot; int pScore = NULL,cScore = NULL;enum winLimit {WIN = 10};welcome();std::string pTeam = teamSelection();std::string cTeam = compSelection();do {printScore(pScore,cScore,cTeam,pTeam);playersShot = playerShoot(pScore,pTeam);printScore(pScore,cScore,cTeam,pTeam);computersShot = computerShoot(cScore,cTeam);}while(pScore != WIN || cScore != WIN);if(pScore == WIN)winMessage(pScore,cScore,pTeam,cTeam);else if(cScore == WIN)loseMessage(pScore,cScore,cTeam,pTeam);return 0;}std::string teamSelection(){system("CLS");std::string team[5];team[0] = "The Warriors";team[1] = "The Skull Crushers";team[2] = "The Big Macs";team[3] = "The Granny's";team[4] = "The John's";int players_team;std::cout << "\n\n\n\t\t\t   Please Pick a Team (1-5):\n\n";std::cout << "\t\t\t-------------------------------" << std::endl;std::cout << "\t\t\t| --------------------------- |" << std::endl;std::cout << "\t\t\t| || |" << std::endl;std::cout << "\t\t\t| | 1) The Warriors    | |" << std::endl;std::cout << "\t\t\t| | 2) The Skull Crushers   | |" << std::endl;std::cout << "\t\t\t| | 3) The Big Macs    | |" << std::endl;std::cout << "\t\t\t| | 4) The Granny's    | |" << std::endl;std::cout << "\t\t\t| | 5) The John's | |" << std::endl;std::cout << "\t\t\t| || |" << std::endl;std::cout << "\t\t\t| --------------------------- |" << std::endl;std::cout << "\t\t\t-------------------------------" << std::endl << std::endl;std::cout << "\t\t\t  Team Selection: ";std::cin >> players_team;return team[players_team-1];}std::string compSelection(){std::string team[5];team[0] = "The Warriors";team[1] = "The Skull Crushers";team[2] = "The Big Macs";team[3] = "The Granny's";team[4] = "The John's";int comp_team = rand() % 5;return team[comp_team-1];}void winMessage(int &pScore, int &cScore, std::string  pTeam, std::string cTeam){system("CLS");std::cout << "Congratulations! You've Defeated " << cTeam << "!!!\n";std::cout << "Final Score:\n\n";std::cout << pTeam << ": " << pScore << std::endl;std::cout << cTeam << ": " << cScore << std::endl << std::endl;std::cout << "Press Enter to Leave the Court.";std::cin.get();}void loseMessage(int &pScore, int &cScore, std::string cTeam, std::string pTeam){system("CLS");std::cout << "Ahhhhh! Too bad You Lost to " << cTeam << "!!!\n";std::cout << "Final Score:\n\n";std::cout << cTeam << ": " << cScore << std::endl;std::cout << pTeam << ": " << pScore << std::endl << std::endl;std::cout << "Press Enter to Leave the Court.";std::cin.get();}void welcome(){std::cout << "\n\n\n\t\t\t---------------------------------------" << std::endl;std::cout << "\t\t\t| ----------------------------------- |" << std::endl;std::cout << "\t\t\t| |   | |" << std::endl;std::cout << "\t\t\t| |  Welcome to The 3 Point Craze!  | |" << std::endl;std::cout << "\t\t\t| |  by: Brandon  Wall    | |" << std::endl;std::cout << "\t\t\t| |   | |" << std::endl;std::cout << "\t\t\t| |  Play Basketball Against The    | |" << std::endl;std::cout << "\t\t\t| |  most Fierce Teams The BBA has  | |" << std::endl;std::cout << "\t\t\t| |  has to Throw your Way!    | |" << std::endl;std::cout << "\t\t\t| |   | |" << std::endl;std::cout << "\t\t\t| ----------------------------------- |" << std::endl;std::cout << "\t\t\t---------------------------------------" << std::endl << std::endl;std::cout << "\t\t\t  Press Enter to Start Picking a Team.";std::cin.get();}void printScore(int  &pScore, int &cScore, std::string cTeam, std::string pTeam){system("CLS");std::cout << "Scores:\n\n";if(pScore >= cScore || pScore == cScore) {std::cout << "1: " << pTeam << " - " << pScore << std::endl;std::cout << "2: " << cTeam << " - " << cScore << std::endl;}else {std::cout << "1: " << cTeam << " - " << cScore << std::endl;std::cout << "2: " << pTeam << " - " << pScore << std::endl;}}int playerShoot(int &pScore, int &cScore, std::string cTeam, std::string pTeam){int ball = rand() % 1;std::vector<std::string> madeShots;madeShots.push_back("Scores a Shwish!");madeShots.push_back("Shoots! He Scores!");madeShots.push_back("Makes a Wonderful Shot.");madeShots.push_back("Made a well aimed Shot!");std::vector<std::string> missShots;missShots.push_back("Shoots an Air Ball...");missShots.push_back("Bricks it... What a Loser!");missShots.push_back("Makes a lame Shot!");missShots.push_back("Choked!");random_shuffle(madeShots.begin(),madeShots.end());random_shuffle(missShots.begin(),missShots.end());if(ball == 1) {std::cout << pTeam << " are up! He Shoots... " << madeShots[0];pScore++;}elsestd::cout << pTeam << " are up! He Shoots... " << missShots[0];return pScore;}int playerShoot(int &cScore, std::string cTeam){int ball = rand() % 1;std::vector<std::string> madeShots;madeShots.push_back("Scores a Shwish!");madeShots.push_back("Shoots! He Scores!");madeShots.push_back("Makes a Wonderful Shot.");madeShots.push_back("Made a well aimed Shot!");std::vector<std::string> missShots;missShots.push_back("Shoots an Air Ball...");missShots.push_back("Bricks it... What a Loser!");missShots.push_back("Makes a lame Shot!");missShots.push_back("Choked!");random_shuffle(madeShots.begin(),madeShots.end());random_shuffle(missShots.begin(),missShots.end());if(ball == 1) {std::cout << cTeam << " are up! He Shoots... " << madeShots[0];cScore++;}elsestd::cout << cTeam << " are up! He Shoots... " << missShots[0];return cScore;}Errors:1>Ch. 12345 Review_ 3 Point Craze.obj : error LNK2019: unresolved external symbol "int __cdecl computerShoot(int &,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > &)" (?computerShoot@@YAHAAHAAV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z) referenced in function _main1>Ch. 12345 Review_ 3 Point Craze.obj : error LNK2019: unresolved external symbol "int __cdecl playerShoot(int &,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > &)" (?playerShoot@@YAHAAHAAV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z) referenced in function _main1>C:\Documents and Settings\Brandon\My Documents\Visual Studio 2005\Projects\Ch. 12345 Review_ 3 Point Craze\Debug\Ch. 12345 Review_ 3 Point Craze.exe : fatal error LNK1120: 2 unresolved externals
  First of all, the first message is telling you that you did not write the computerShoot() function anywhere in your code. You call it, but you don't write it anywhere so the compiler doesn't know what to do when it reaches the computerShoot() function. The same thing goes for the playerShoot function. While you did write a playerShoot() function, it has a different set of parameters. Make sure your functions are right and all written out, and then try again.   ;Quote:Original post by ussnewjersey4First of all, the first message is telling you that you did not write the computerShoot() function anywhere in your code. You call it, but you don't write it anywhere so the compiler doesn't know what to do when it reaches the computerShoot() function. The same thing goes for the playerShoot function. While you did write a playerShoot() function, it has a different set of parameters. Make sure your functions are right and all written out, and then try again.Thanks for the explaination.After fixing those problems, it looks like the same errors are coming up! Ive looked at the 2 functions declared, defined, and it doesnt look different at all... Please help me figure this thing out Source:#include "stdafx.h"#include <ctime>#include <string>#include <iostream>#include <vector>#include <algorithm>std::string teamSelection();std::string compSelection();int playerShoot(int pScore, std::string pTeam);int computerShoot(int cScore, std::string cTeam);void welcome();void printScore(int &pScore, int &cScore, std::string cTeam, std::string pTeam);void winMessage(int &pScore, int &cScore, std::string cTeam, std::string pTeam);void loseMessage(int &pScore, int &cScore, std::string cTeam, std::string pTeam);int main(){srand(time(0));int playersShot,computersShot; int pScore = NULL,cScore = NULL;enum winLimit {WIN = 10};welcome();std::string pTeam = teamSelection();std::string cTeam = compSelection();do {printScore(pScore,cScore,cTeam,pTeam);playersShot = playerShoot(pScore,pTeam);printScore(pScore,cScore,cTeam,pTeam);computersShot = computerShoot(cScore,cTeam);}while(playersShot != WIN || computersShot != WIN);if(playersShot == WIN)winMessage(pScore,cScore,pTeam,cTeam);else if(computersShot == WIN)loseMessage(pScore,cScore,cTeam,pTeam);return 0;}std::string teamSelection(){system("CLS");std::string team[5];team[0] = "The Warriors";team[1] = "The Skull Crushers";team[2] = "The Big Macs";team[3] = "The Granny's";team[4] = "The John's";int players_team;std::cout << "\n\n\n\t\t\t   Please Pick a Team (1-5):\n\n";std::cout << "\t\t\t-------------------------------" << std::endl;std::cout << "\t\t\t| --------------------------- |" << std::endl;std::cout << "\t\t\t| || |" << std::endl;std::cout << "\t\t\t| | 1) The Warriors    | |" << std::endl;std::cout << "\t\t\t| | 2) The Skull Crushers   | |" << std::endl;std::cout << "\t\t\t| | 3) The Big Macs    | |" << std::endl;std::cout << "\t\t\t| | 4) The Granny's    | |" << std::endl;std::cout << "\t\t\t| | 5) The John's | |" << std::endl;std::cout << "\t\t\t| || |" << std::endl;std::cout << "\t\t\t| --------------------------- |" << std::endl;std::cout << "\t\t\t-------------------------------" << std::endl << std::endl;std::cout << "\t\t\t  Team Selection: ";std::cin >> players_team;return team[players_team-1];}std::string compSelection(){std::string team[5];team[0] = "The Warriors";team[1] = "The Skull Crushers";team[2] = "The Big Macs";team[3] = "The Granny's";team[4] = "The John's";int comp_team = rand() % 5;return team[comp_team-1];}void winMessage(int &pScore, int &cScore, std::string  pTeam, std::string cTeam){system("CLS");std::cout << "Congratulations! You've Defeated " << cTeam << "!!!\n";std::cout << "Final Score:\n\n";std::cout << pTeam << ": " << pScore << std::endl;std::cout << cTeam << ": " << cScore << std::endl << std::endl;std::cout << "Press Enter to Leave the Court.";std::cin.get();}void loseMessage(int &pScore, int &cScore, std::string cTeam, std::string pTeam){system("CLS");std::cout << "Ahhhhh! Too bad You Lost to " << cTeam << "!!!\n";std::cout << "Final Score:\n\n";std::cout << cTeam << ": " << cScore << std::endl;std::cout << pTeam << ": " << pScore << std::endl << std::endl;std::cout << "Press Enter to Leave the Court.";std::cin.get();}void welcome(){std::cout << "\n\n\n\t\t\t---------------------------------------" << std::endl;std::cout << "\t\t\t| ----------------------------------- |" << std::endl;std::cout << "\t\t\t| |   | |" << std::endl;std::cout << "\t\t\t| |  Welcome to The 3 Point Craze!  | |" << std::endl;std::cout << "\t\t\t| |  by: Brandon  Wall    | |" << std::endl;std::cout << "\t\t\t| |   | |" << std::endl;std::cout << "\t\t\t| |  Play Basketball Against The    | |" << std::endl;std::cout << "\t\t\t| |  most Fierce Teams The BBA has  | |" << std::endl;std::cout << "\t\t\t| |  has to Throw your Way!    | |" << std::endl;std::cout << "\t\t\t| |   | |" << std::endl;std::cout << "\t\t\t| ----------------------------------- |" << std::endl;std::cout << "\t\t\t---------------------------------------" << std::endl << std::endl;std::cout << "\t\t\t  Press Enter to Start Picking a Team.";std::cin.get();}void printScore(int  &pScore, int &cScore, std::string cTeam, std::string pTeam){system("CLS");std::cout << "Scores:\n\n";if(pScore >= cScore || pScore == cScore) {std::cout << "1: " << pTeam << " - " << pScore << std::endl;std::cout << "2: " << cTeam << " - " << cScore << std::endl;}else {std::cout << "1: " << cTeam << " - " << cScore << std::endl;std::cout << "2: " << pTeam << " - " << pScore << std::endl;}}int playerShoot(int &pScore, std::string pTeam){int ball = rand() % 1;std::vector<std::string> madeShots;madeShots.push_back("Scores a Shwish!");madeShots.push_back("Shoots! He Scores!");madeShots.push_back("Makes a Wonderful Shot.");madeShots.push_back("Made a well aimed Shot!");std::vector<std::string> missShots;missShots.push_back("Shoots an Air Ball...");missShots.push_back("Bricks it... What a Loser!");missShots.push_back("Makes a lame Shot!");missShots.push_back("Choked!");random_shuffle(madeShots.begin(),madeShots.end());random_shuffle(missShots.begin(),missShots.end());if(ball == 1) {std::cout << pTeam << " are up! He Shoots... " << madeShots[0];pScore++;}elsestd::cout << pTeam << " are up! He Shoots... " << missShots[0];return pScore;}int computerShoot(int &cScore, std::string cTeam){int ball = rand() % 1;std::vector<std::string> madeShots;madeShots.push_back("Scores a Shwish!");madeShots.push_back("Shoots! He Scores!");madeShots.push_back("Makes a Wonderful Shot.");madeShots.push_back("Made a well aimed Shot!");std::vector<std::string> missShots;missShots.push_back("Shoots an Air Ball...");missShots.push_back("Bricks it... What a Loser!");missShots.push_back("Makes a lame Shot!");missShots.push_back("Choked!");random_shuffle(madeShots.begin(),madeShots.end());random_shuffle(missShots.begin(),missShots.end());if(ball == 1) {std::cout << cTeam << " are up! He Shoots... " << madeShots[0];cScore++;}elsestd::cout << cTeam << " are up! He Shoots... " << missShots[0];return cScore;}Errors:1>Ch. 12345 Review_ 3 Point Craze.obj : error LNK2019: unresolved external symbol "int __cdecl computerShoot(int,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >)" (?computerShoot@@YAHHV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z) referenced in function _main1>Ch. 12345 Review_ 3 Point Craze.obj : error LNK2019: unresolved external symbol "int __cdecl playerShoot(int,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >)" (?playerShoot@@YAHHV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z) referenced in function _main1>C:\Documents and Settings\Brandon\My Documents\Visual Studio 2005\Projects\Ch. 12345 Review_ 3 Point Craze\Debug\Ch. 12345 Review_ 3 Point Craze.exe : fatal error LNK1120: 2 unresolved externals;  Well, now your functions and calls are all right. Your problem now is that the prototypes that you define before the main() function are different from the actual functions that you wrote. Specifically, the ones before main() have a header of playerShoot( int, std::string ), while the ones that you wrote the body for have a header of playerShoot( int&, std::string ). Its probably just a typo, and it's merely a case of mismatched functions. I think you want the function to use a pass by reference, so your prototypes should look like:int playerShoot(int &pScore, std::string pTeam);int computerShoot(int &cScore, std::string cTeam);I think you had it right the first time there.   ;Quote:Original post by ussnewjersey4Well, now your functions and calls are all right. Your problem now is that the prototypes that you define before the main() function are different from the actual functions that you wrote. Specifically, the ones before main() have a header of playerShoot( int, std::string ), while the ones that you wrote the body for have a header of playerShoot( int&, std::string ). Its probably just a typo, and it's merely a case of mismatched functions. I think you want the function to use a pass by reference, so your prototypes should look like:*** Source Snippet Removed ***I think you had it right the first time there.Cant believe i didnt see that!Thank you very much my good man! [lol]