problem with returning a specific type

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;


Schedule:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
#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(const int 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(const int 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 


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
#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(const int 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(const int 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;	
}
	
}
Last edited on
It can't find your main() function.
Thanks
Topic archived. No new replies allowed.