Trying to to a database type prgram C++

So this is my beginning of a student database in C++.

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
#include <iostream>
#include <conio.h>
#include <string>
using namespace std;

/* Declaration of variables */

string Name, MEG, Grade, Progress;
int Age, MEGN, GradeN;

/* Declaration of functions */

void TomSmith();





int main()
{
    cout << "Input surname and press ENTER" << endl;
    cin >> Name;
    if (Name == Smith);
        TomSmith();

    return 0;
}

void TomSmith()
{
    cout << "Name: Tom Smith" << endl;
    Age = 16;
    cout << "Age :" << Age << endl;
    MEG = A;
    MEGN = 5;
    cout << "MEG:" << MEG << endl;
    Grade = B;
    GradeN = 4;
    cout << "Grade:" << Grade << endl;
        if (Grade > MEG)
            Progress = Above
        else if (Grade == MEG)
            Progress = On
        else
            Progress = Below
    cout << "Progress:" << Progress << endl;

}


I'm getting quite a few errors -

||=== Student Database, Debug ===|
In function 'int main()':|
error: 'Smith' was not declared in this scope|
In function 'void TomSmith()':|
'A' was not declared in this scope|
'B' was not declared in this scope|
'Above' was not declared in this scope|
expected ';' before 'else'|
||=== Build finished: 5 errors, 0 warnings (0 minutes, 0 seconds) ===|

I'm probably doing this completely wrong, but I'm still a complete noob, and I really don;t understand the errors.



Last edited on
Instead of
1
2
if (Name == Smith);
TomSmith();

you have to do
1
2
3
4
if (Name == "Smith")
{
TomSmith();
}

(The braces don't have to be there, but you should include them in case you want to add more statements to the loop)
Still get the same error :)

Ty

Tom
Sorry, I kind of looked only at your first error :D

MEG = A; has to be MEG = 'A';

and
Grade = B; has to be Grade = 'B';

and
Progress = Above has to be Progress = "Above";
same for setting progress to "on" or "below"

Also I don't exactly understand why do you have
#include <conio.h>
as the code you wrote doesn't use it and if you need it just keep in mind that it's not a very good library to use even though it has useful functions, you can find some articles about that

Don't try to set a variable to a letter without putting quotes around it, otherwise the compiler thinks A and B are also variables, which you have not declared. And don't forget semi colons :)
Last edited on
Thank you. Its people like you that are helping me get better and becoming more interested in C++ all the time :)

Thank You!

Tom
You're absolutely welcome! :)

Now why don't you mark this topic as solved ?
Topic archived. No new replies allowed.