
i have error in my cod when i build programthe header
#ifndef STUDENT_H_ #define STUDENT_H_ #include <iostream> using namespace std; #include <string> using namespace std; class Student{ private: static int serialId; const int id; string name; int currentCourses; bool canRegisterMore(); public: Student(string studentName); bool registerCourse(); void dropCourse(); void printDetails(); }; #endif /*STUDENT_H_*/
the .cpp
#include"Student.h" int Student::serialId=0; Student::Student(string studentName):id(serialId)//intilizer member list { name=studentName; currentCourses=0; serialId++; } bool Student::canRegisterMore() { if(currentCourses<4) return true; else return false; } bool Student::registerCourse() { if(canRegisterMore()==true) { return true; cout<<"you can Register course"; currentCourses++; else return false; cout<<"Sory you cannot Register course !"; } } void Student::dropcourse() { if (currentCourses>0) { currentCourses--; else cout<<"Error!" } } void Student::printDetails() { cout<<"The student name is:\n"<<studentName; cout<<"The student ID is:\n"<<id; cout<<"The currentCourses is:\n"<<currentCourses<<endl; cout<<"The student abilety for registr corse is:\n"<<registerCourse(); }
the main
#include"Student.h" int main() { Student StudentObj("Ameerah"); StudentObj.printDetails(); return 0; }
the error mesge is:
--------------------Configuration: main - Win32 Debug--------------------
Linking...
main.obj : error LNK2001: unresolved external symbol "public: void __thiscall Student::printDetails(void)" ([email protected]@@QAEXXZ)
main.obj : error LNK2001: unresolved external symbol "public: __thiscall Student::Student(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >)" ([email protected]@[email protected]?$[email protected]?$[email protected]@[email protected]@V?$[email protected]
[email protected]@@[email protected]@@Z)
Debug/main.exe : fatal error LNK1120: 2 unresolved externals
Error executing link.exe.
main.exe - 3 error(s), 0 warning(s)
pleas help me because i must give the tetcher on sturday
