I have an odd degub error, and I'm not sure what's causing it.

Here is a class for my first real project (nothing too complicated.)
1
2
3
4
5
6
7
8
9
class player
{
     public:
     string sName;
     int nDiff;
     void Giveinfo();
     void Getinfo();
     int Getdiff();       
}

I'm not getting the debug error there, but
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
int player::Getdiff()
{
    int d;
    bool iscorrect;
    for (iscorrect != true) {  
        cout << "Please type 1, 2, or 3 for the level \n of difficulty you would like" << endl;
        cin >> d;
        iscorrect=true;
        if (d>3) {
           cout << "That's more than 3, lets try this again..." << endl;
           iscorrect=false;
        }
        else if (d<1) {
             cout << "That's less than 1, lets try this again..." << endl;
             iscorrect=false;
        }
    }
    return = d;
}

on the first line of that function. It's telling me that
23 C:\Dev-Cpp\My .devs\blackjack.cpp new types may not be defined in a return type

and
23 C:\Dev-Cpp\My .devs\blackjack.cpp prototype for `player player::Getdiff()' does not match any in class `player'

but I see nothing wrong with my function definition.
And of course, I have
1
2
3
4
5
6
7
#include <cstdlib>
#include <iostream>
#include <strings.h>

using namespace std;
using std::string;
using std::endl;

at the top.

So, if you see anything wrong with the function or need the full code, let me know :D Thanks!
you are missing a semicolon after class player { };

Thanks :D That got rid of that error.
But now I have new ones haha!
Here's the new (full) code;
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
#include <cstdlib>
#include <iostream>
#include <strings.h>

using namespace std;
using std::string;
using std::endl;

//classes
class player
{
     public:
     string sName;
     int nDiff;
     void Giveinfo(void);
     void Getinfo(void);
     int Getdifficulty(void);       
};

player s;

int main(int argc, char *argv[])
{
    s.Getinfo();
    system("PAUSE");
    return EXIT_SUCCESS;
};
/*
FUNCTIONS ARE BELOW
*/

int player::Getdifficulty(void)
{
    int d;
    bool iscorrect;
    for (iscorrect != true)
    {  
        cout << "Please type 1, 2, or 3 for the level \n of difficulty you would like" << endl;
        cin >> d;
        iscorrect=true;
        if (d>3) {
           cout << "That's more than 3, lets try this again..." << endl;
           iscorrect=false;
        };
        else if (d<1) {
             cout << "That's less than 1, lets try this again..." << endl;
             iscorrect=false;
        };
    };
    return d;
};


void player::Getinfo(void)
{
     cout << "Please type your name" << endl;
     cin >> sName;
     nDiff = Getdifficulty();
     return;
};

void player::Giveinfo(void)
{
     cout << "Your name is " << sName << "." << endl;
     cout << "Your opponent is a CPU. " << endl;
     return;
};

It wants
36 C:\Dev-Cpp\My .devs\blackjack.cpp expected `;' before ')' token

and
50 C:\Dev-Cpp\My .devs\blackjack.cpp expected `;' before "return"
50 C:\Dev-Cpp\My .devs\blackjack.cpp expected primary-expression before "return"
50 C:\Dev-Cpp\My .devs\blackjack.cpp expected `)' before "return"
You're ending all of your functions in semicolons. Drop the ;
Actually, that isn't the problem, you can end functions with ';' and it won't complain. The problem is:

for (iscorrect != true)

I think you meant to use a 'while' loop.
Ah, the while loop should help! Thanks!
Oh, will that exit right when iscorrect turns true, or will it exit at the end of the cycle?
while loops check the condition at the very beginning, so if the condition evaluates false in the first time, the whole body is skipped.

You can initialize iscorrect on line 35 to ensure that it's false. A better way would be a do...while loop.
Topic archived. No new replies allowed.