Problem with Linker Subsystem Settings...

Hello, i had to write a program for class that met the following criteria:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
Create a class named Student that has three member variables:
name – A string that stores the name of the student
numClasses – An integer that tracks how many courses the
  student is currently enrolled in
classList – A dynamic array of strings used to store the names
  of the classes that the student is enrolled in
  Write appropriate
  constructor(s),
  mutator, and
  accessor methods for the class along
  with the following:
  - A method that inputs all values from the user, including the list of class names.
    This method will have to support  input for an arbitrary number of classes.
  - A method that outputs the name and list of all courses.
  - A method that resets the number of classes to 0 and the classList to an empty list.
  - An overloaded assignment operator that correctly makes a new copy of the list of
    courses.
  - A destructor that releases all memory that has been allocated.
  Write a main method that tests all of your functions.


This is what i have written so far:

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
#include <iostream>
#include <cstdlib>
#include <string>
using namespace std;
class Student
{
	public: Student();
	~Student();
	void InputData(); // Input all data from user
	void OutputData(); // Output class list to console
	void ResetClasses(); // Reset class list
	Student& operator =(const Student& rightSide);// Assignment operator

	private: 
	  string name;
	  int numClasses;
	  string *classList;
};


#include <iostream>
#include <iomanip>
using namespace std;

Student::Student() : name(""), numClasses(0), classList(NULL)
  {
  }

// Student::~Student

Student::~Student()
  {
  numClasses = 0;
  ResetClasses();
  name = "";
  }

// Student::ResetClasses

void Student::ResetClasses()
  {
  if (classList) {
    delete [] classList;
    classList = NULL;
    numClasses = 0;
    }
  }

// Student::InputData

void Student::InputData()
  {
  // Reset the class list just in case this method
  // was called again and the dynamic array wasn't cleared
  ResetClasses();
  cout << "Enter student name > ";
  getline(cin, name);
  cout << "Enter number of classes > ";
  cin >> numClasses;
  cin.ignore(2,'\n'); // Discard extra newline
  if (numClasses > 0) {
    // Dynamically construct array large enough to hold the
    // number of classes
    classList = new string[numClasses];
    // Loop through the number of classes, inputting
    // the name of each one into our dynamic array
    for (int i=0; i<numClasses; i++) {
      cout << "Enter name of class " << (i+1) << " > ";
      getline(cin, classList[i]);
      }
    }
  cout << endl;
  }

// Student::OutputData

void Student::OutputData()
  {
  cout << "Name of Student: " << name << endl
       << "Class List: " << endl;
  for (int i = 0; i < numClasses; i++) {
    cout << setw(2) << right << i + 1 << ") " << classList[i] << endl;
    }
  }

// Student::=

Student& Student::operator =(const Student& rightSide)
  {
  ResetClasses();
  numClasses = rightSide.numClasses;
  if (numClasses > 0) {
    classList = new string[numClasses];
    for (int i = 0; i < numClasses; i++) {
      classList[i] = rightSide.classList[i];
      }
    }
  
  return *this;
  }

// test function

void student()
{
// Test our code with two student classes
Student s1, s2;
s1.InputData(); // Input data for student 1
cout << "Student 1's data:" << endl;
s1.OutputData(); // Output data for student 1
cout << endl;
s2 = s1;
cout << "Student 2's data after assignment from student 1:" << endl;
s2.OutputData(); // Should output same data as for student 1
s1.ResetClasses();
cout << "Student 1's data after reset:" << endl;
s1.OutputData(); // Should have no classes
cout << "Student 2's data, should still have original classes:" << endl;
s2.OutputData(); // Should still have original classes
cout << endl;
}



The errors i keep getting are either THIS:
unresolved external symbol _main referenced in function ___tmainCRTStartup
fatal error LNK1120: 1 unresolved externals

OR THIS:
error LNK2019:unresolved external symbol _WinMain@16 referenced in function ___tmainCRTStartup
fatal error LNK1120: 1 unresolved externals

I googled both these issues and every answer was to switch the Linker SubSystem to Console or Windows depending on the error (THIS IS SUPPOSE TO BE A CONSOLE APPLICATION). Whether the SubSystem is Console or Windows i get those errors. Please can anybody help me with this!

Thank you

Edit: added the test function
Last edited on
I don't know what you google'd but you need to have an entry point for your program to work. This is is defined as the "int main()" function by default.
Wow forgot the simplest of things. Finals Week XD
Topic archived. No new replies allowed.