Ok in my project i Have the following three files:
Main.cpp:
gkfunc.cpp:Code:#include <iostream> #include <stdlib.h> #include <wincon.h> #include "GKinfo.h" using namespace std; //main function to find out options int main() { std::cout<<"\n\n:::::::::: ::::::::::\n" <<":::::::::: G R A D E K E E P E R ::::::::::\n" <<":::::::::: ::::::::::\n"; while(1) { cout<<"\n\n\nM E N U" <<"\n[1]:Add a course" <<"\n[2]:Add points (assignment)" <<"\n[3]:View a course's information" <<"\n[4]:Exit\nChoice:"; int choice; std::cin>>choice; if(choice==1) { getdata(c); } if(choice==3) { std::cout<<"\nPlease enter the course hour:"; std::cin>>selecthour; readdata(c, selecthour); } if(choice==2) { cout<<"\nPlease enter the hour this assignment was for:"; cin>>inputhour; addassign(c, inputhour); } if(choice==4) { return 0; } } return 0; }
and gkinfo.h:Code:#include <iostream> #include <stdlib.h> #include <wincon.h> #include "GKinfo.h" using namespace std; void addassign(course* c, int inputhour) { cout<<"\nPlease enter the points you got on the assignment:"; cin>>yourscore; cout<<"\nPlease enter the total points from the assignment:"; cin>>totalscore; c[inputhour].nCurrentPoints+=yourscore; c[inputhour].nMaxPoints+=totalscore; gradevar=(c[inputhour].nCurrentPoints/c[inputhour].nMaxPoints); if(gradevar>=0.9) { newgrade='A'; } else if(gradevar>=0.8) { newgrade='B'; } else if(gradevar>=0.7) { newgrade='C'; } else if(gradevar>=0.6) { newgrade='D'; } else if(.59>=gradevar) { newgrade='E'; } c[inputhour].cGrade=newgrade; } void readdata(course* c, int selecthour) { double pcent=100*(c[inputhour].nCurrentPoints/c[inputhour].nMaxPoints); cout<<"\nCourse name:"<<c[selecthour].CourseName<<"\nHour:"<<c[selecthour].nHour; cout<<"\nCurrent points:"<<c[selecthour].nCurrentPoints<<"\nTotal Points:"<<c[selecthour].nMaxPoints; cout<<"\nCurrent gade:"<<c[selecthour].cGrade; cout<<"\nPercent:"<<pcent<<"%"; //cin.get(); } void getdata(course* x) { std::cout<<"\nPlease enter an hour:"; std::cin>>inputhour; c[inputhour].nHour=inputhour; std::cout<<"\nPlease enter a course name:"; std::cin>>c[inputhour].CourseName; //system("PAUSE"); }
Ok it appears my error is coming from the variable declarations. The errors I get when I try to compile is the same: "gkfunc.cpp multiple definition of `*insertvariablenamehere*' ", "main.cpp first defined here ".Code:#ifndef _GKINFO_H #define _GKINFO_H #include <iostream> #include <stdlib.h> #include <wincon.h> class course { public: int nHour; char cGrade; double nMaxPoints; double nCurrentPoints; char CourseName[255]; }; /////////////////////////////////////////////////////////////// void addassign(course* c, int inputhour); void readdata(course* c, int selecthour); void getdata(course* x); /////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////// //////VARIABLE DECLARATIONS//////////////////////////////////// double yourscore; //Used to tell what you got on the assignment double totalscore; //Used to tell what the total points of the assignment was int selecthour; //used to bring up the selected hour int inputhour=1; //used to insert the hour double gradevar; //Used to help decide the grade char newgrade; course c[25]; /////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////// #endif
Now I know these variables aren't found in any other file so I don't know WHY they would be getting multiple definitions. Does anybody know why I'm getting this error?



LinkBack URL
About LinkBacks




