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!

Recommended Answers

All 2 Replies

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!

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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.