0

Hi, I'm trying to write a program using enum to store data. The user needs to input the first two letters of a word and the program outputs the full word. Here is what I have, but for some reason I cannot get it to run (visual c++ express edition).

#include <iostream>

using namespace std;

enum courses {ALGEBRA, ANALYSIS, BASIC};

int main()

courses readCourses()
{
	courses registered;
	char ch1, ch2;

	cout << "Enter the first two letters of the course: "
		 << endl;
	cin >> ch1 >> ch2;

switch (ch1)
{
case 'a':
case 'A':
	if (ch2 == '1' || ch2 == 'L')
		registered = ALGEBRA;
	else 
		registered = ANALYSIS;
	break;
case 'b':
case 'B':
	registered = BASIC;
	break;
default:
	cout << "Illegal input. " << endl;
}
    return registered;

}

here are the errors im getting:
error C3646: 'courses' : unknown override specifier
error C3646: 'readCourses' : unknown override specifier
error C2091: function returns function
error C2440: 'return' : cannot convert from 'courses' to 'int (__cdecl *)(void)'

This program isn't what I want my final program, but I'm just trying to see if I can get this to work before I put it all the extra stuff. Thanks!

2
Contributors
2
Replies
3
Views
7 Years
Discussion Span
Last Post by Olah92
0

You have need to organize your program more like this:
// add function prototype here
int main()
{
// add code to call your function
}

// move your function readCourses OUTSIDE main
courses readCourses()
{
}

good luck!

0

You have need to organize your program more like this:
// add function prototype here
int main()
{
// add code to call your function
}

// move your function readCourses OUTSIDE main
courses readCourses()
{
}

good luck!

I'll try that, thanks.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.