Syntax is correct, but won't compile?

I've been stuck at this part in my code for a bit
basically.The error comes in at line 21 and 13, but I don't understand the errors

21 G:\program5.cpp new types may not be defined in a return type
21 G:\program5.cpp two or more data types in declaration of `setKey'
21 G:\program5.cpp prototype for `TestGrade TestGrade::setKey(char*)' does not match any in class `TestGrade'
13 G:\program5.cpp void TestGrade::setKey(char*)
21 G:\program5.cpp `TestGrade TestGrade::setKey(char*)' and `void TestGrade::setKey(char*)' cannot be overloaded

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
 


#include<iostream>
#include<string>


using namespace std;


 class TestGrade
 {
 public: void setKey(char []);
		 void grade(char []);
		 char canswers[20];
 } 



	void TestGrade::setKey(char answers[])
	{
		for(int index = 0; index < 20; index++)
		{
			canswers[index] = answers[index];
		}
	}




int main()
{
	const char SIZE = 20;
	char answer[SIZE];
	char answers[20] = {'B', 'D', 'A', 'A',
						'C', 'A', 'B', 'A',
						'C', 'D', 'B', 'C',
						'C', 'B', 'D', 'A'};




	cout << "Welcome to the written portion of the DMV exam. \n";
	cout << "You may only enter capital A, B, C, or D for your answers.\n\n" << endl;



	for (int index = 0; index < SIZE; index++)

	{
		cout << "Enter your answer for question " << index+1 << endl;
		cin >> answer[index];


		while (answer[index] != 'A'
			&& answer[index] != 'B'
			&& answer[index] != 'C'
			&& answer[index] != 'D')
	{
		cout << "ERROR: you must input capital A,B,C, or D" << endl;
		cin >> answer[index];
	}

	}


system("pause");
return 0;

}
Last edited on
Your class needs to end with a semi-colon ( line 16 )
its funny how little things like that can throw off the whole flow of the program.
thanks man
Topic archived. No new replies allowed.