I get two errors: 1 unresolved external and Error 3 error LNK2019: unresolved external symbol _main referenced in function ___tmainCRTStartup C:\Users\user1\Documents\Visual Studio 2010\Projects\HW2\HW2\MSVCRTD.lib(crtexe.obj)
what do they mean? if anyone can tell me where the error line is that would help me a lot.
thanks in advance.
1 2 3 4 5
class Course {
private:
std::string _name;
int _number;
std::string _faculty;
#ifndef _SCHEDULE_H_
#define _SCHEDULE_H_
#include <string>
#include <list>
#include <iostream>
#include "Course.h"
/*
* Class which holds list of courses and provides API to
* manage that list by adding, removing courses to it, as
* well provides API to retrive courses using course unique
* number.
*/
// template <template <class, class> class Container>
class Schedule {
private:
int num; //number of courses
int max; //the maximum size of the schedule list
std::list<Course> courses;
public:
/*
* Enumeration which indicates operation status for
* part of Schedule API.
*
* Ok - operation completed succesefully
* Failure - an error occured during operation
* Already_Exist - status which indicates fact of trying
* to add course to the list which already exist in the
* list
* Not_Found - trying to find course which doesn't
* exists in the list
*/
enum Result { Ok, Failure, Already_Exist, Not_Found };
/*
* Constructor which receives maximum size of the schedule
* list.
*/
Schedule(int size);
/*
* Add new course to the list
*
* Return:
* Ok - on success
* Already_Exist - course already exists in the list
* Failure - undefined error situation
*/
Result addCourse(const Course& course);
/*
* Remove course from the list
*
* Return:
* Ok - course successefully removed
* Not_Found - trying to remove course which is not
* exist in the list
* Failure - undefined error situation
*/
Result removeCourse(constint number);
/*
* Clean courses list, e.g. remove all courses from the
* list.
*/
Schedule& removeAll();
/*
* Return array with all courses from schedule
*/
Course* getAllCourses(); //to be changed to the function with the container
/*
* Find course in the list with given course number
*
* Returns:
* 1. Course with given number in cases list holds such
* 2. NULL in case course was not found
*/
Course* findCourse(constint number);
/*
* See addCourse.
*/
Schedule& operator+=(const Course& course);
/*
* See removeCourse.
*/
Schedule& operator-=(const Course& course);
/*
* Return number of courses in the list
*/
int getCoursesNumber() const;
/*
* Output on the screen courses schedule list sorted by
* course number.
*/
Schedule& print(std::ostream& os);
};
#endif
#include "Schedule.h"
/*ctor*/
Schedule::Schedule(int size){
max=size;
}
/*operators*/
Schedule& Schedule::operator+=(const Course& course){
this->addCourse(course);
return *this;
}
Schedule& Schedule::operator-=(const Course& course){
this->removeCourse(course.getNumber());
return *this;
}
/*get function*/
int Schedule::getCoursesNumber() const {
return num;
}
/*print function*/
Schedule& Schedule::print(std::ostream& os){
std::list<Course>::iterator it = courses.begin();
std::list<int> temp;
std::list<int>::iterator it1;
for (it1 = temp.begin(); it1 != temp.end(); ++it1)
{
*it1=it->getNumber();
it++;
}
temp.sort();
std::cout << "list of courses:";
for (it1 = temp.begin(); it1 != temp.end(); ++it1)
std::cout << ' ' << *it1;
std::cout << '\n';
return *this;
}
/*remove*/
Schedule::Result Schedule::removeCourse(constint number){
bool i=true;
// delete from the list of courses
// is registered? if not return not registered
std::list<Course>::iterator it = courses.begin();
// go over the list and search for the id given
while (i==true){
while (it != courses.end()) {
if (it->getNumber() == number){
courses.erase(it);
num = num - 1;
cout << "You have removed a course from your list of courses!" << endl;
i=false;
return Ok;
}
it++;
}
std::cout << "Course was not found to be removed. Try again a different course number" << endl;
i=false;
return Not_Found;
}
return Failure;
}
Schedule& Schedule::removeAll(){
std::list<Course>::iterator it = courses.begin();
for (it = courses.begin(); it != courses.end(); ++it)
courses.erase(it);
num = 0;
std::cout << "You have removed all the courses from the list.";
return *this;
}
Schedule::Result Schedule::addCourse(const Course& course){
std::list<Course>::iterator it = courses.begin();
if (findCourse(course.getNumber()) != NULL)
{
std::cout << "Course Already exists. Cannot be added to the list again." << endl;
return Already_Exist;
}
if (max > (num + 1)){
courses.push_front(course);
num += 1;
cout << "Course was added successfully." << endl;
return Ok;
}
else{
std::cout << "You have reached the maximum size" <<endl;
return Failure;
}
}
Course* Schedule::getAllCourses(){
Course array[50]; // create an array
int x;
std::list<Course>::iterator it = courses.begin();
for(x=0;x<50;x++){
array[x].setNumber(it->getNumber());
it++;
}
return array;
}
Course* Schedule::findCourse(constint number){
Course array[50]; // create an array
int x=0;
std::list<Course>::iterator it = courses.begin();
for(x=0;x<50;x++){
array[x].setNumber(it->getNumber());
it++;
}
while (it!=courses.end()){
if (number == it->getNumber()) {
std::cout << "Course was found" << endl;
return array;
}
++it;
}
std::cout << "Course was not found." << endl;
return NULL;
}
}