Hello,
I've been trying to find a solution to this problem, but none of them have worked so far. I know which line of code is causing the error, but not how to stop it.
I google searched for a solution, and tryed a bunch of things, such as making sure my program was a 32console application, and I was calling the header file correctly, as well as trying to find what it was that wasn't linking, but I don't have a lot of experiance, and whatever I'm missing, I can't seem to find it.
Error Message:
1>------ Build started: Project: annoting, Configuration: Debug Win32 ------
1>Main.obj : error LNK2019: unresolved external symbol "int __cdecl Equation(char)" (?Equation@@YAHD@Z) referenced in function _main
1>C:\Users\User\Documents\Visual Studio 2010\Projects\annoting\Debug\annoting.exe : fatal error LNK1120: 1 unresolved externals
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
main.cpp
Functions.cppCode:#include <iostream> #include <string> #include <conio.h> #include <time.h> #include "functions.h" using namespace std; typedef struct node{ int num1, num2; int data; node *next; }; int Equation(char oper); int main(){ int enemies=30, age, result, guess, score=0; string username; char mode; node *head=NULL; node *temp; temp=(node*)malloc(sizeof(node)); cout<<"Please enter your first name: \t"; cin>>username; cout<<"Please enter your age: \t"; cin>>age; mode =1; int i=enemies; while(i>0){ temp->data=Equation(mode);//This is the line I have to take out inorder for the code to compile. temp->next=head; head=temp; i--; } cin>>guess; temp=temp->next; result=temp->data; if(guess==result){ enemies=enemies-1; score=score+1; cout<<"\nThere are "<<enemies<<" enemies left!\n\tYour score is "<<score<<"!\n"; } else{ cout<<"\nThe correct answer was "<<result<<"\n"; } _getch(); return 0; }
functions.hCode:#include <iostream> #include <string> #include <time.h> #include <conio.h> #include "functions.h" using namespace std; int demon::Equation(char oper){ int int_1, int_2, result; srand(time(NULL)); int_1=1+rand()%5; int_2=1+rand()%5; if(oper='1'){ result = int_1+int_2; cout<<int_1<<"+"<<int_2<<"=\t"; } else{ result = int_1-int_2; cout<<int_1<<"-"<<int_2<<"=\t"; } return result; }
I am running Microsoft Visual Studios 2010 ExpressCode:#ifndef Guy_H_ #define Guy_H_ #include <iostream> #include <string> #include <conio.h> #include <time.h> using namespace std; class Guy{ protected: bool live; public: int distance; }; class demon: public Guy{ private: int answer; char oper; public: int Equation(char oper); }; #endif
Any ideas of what might be causing the problem would help. Thank you.



LinkBack URL
About LinkBacks



