Discussion:
A4Q3 Given code seems to produce an error
(too old to reply)
Ian Toffelmire
2011-06-30 01:40:13 UTC
Permalink
I have coded question 3, but am getting the following error from the
given code
class Umpire {
// YOU MAY ADD MEMBERS
Umpire( Player::Players &players );
void start();
};

Errors that refer to the Umpire( Player::Players &players ); line:
error C2027: use of undefined type 'Player'
error C2061: syntax error : identifier 'Players'

I currently forward declare the Player class, but cannot seem to
forward declare the Players structure so that this works.
If I were allowed to modify this code, I believe I have found a work
around, but "you may NOT change or remove from any of the GIVEN
interface declarations or add any additional public declarations".

What am I supposed to do with these errors?

Thanks for any help,
Ian Toffelmire
Terry Anderson
2011-06-30 01:58:58 UTC
Permalink
Make sure you are using the most recent version of the provided code
(changed as of June 27th).
--
Terry Anderson
CS 246 Instructor
Post by Ian Toffelmire
I have coded question 3, but am getting the following error from the
given code
class Umpire {
// YOU MAY ADD MEMBERS
Umpire( Player::Players &players );
void start();
};
error C2027: use of undefined type 'Player'
error C2061: syntax error : identifier 'Players'
I currently forward declare the Player class, but cannot seem to
forward declare the Players structure so that this works.
If I were allowed to modify this code, I believe I have found a work
around, but "you may NOT change or remove from any of the GIVEN
interface declarations or add any additional public declarations".
What am I supposed to do with these errors?
Thanks for any help,
Ian Toffelmire
Ian Toffelmire
2011-07-01 23:09:25 UTC
Permalink
Post by Terry Anderson
Make sure you are using the most recent version of the provided code
(changed as of June 27th).
--
Terry Anderson
CS 246 Instructor
Post by Ian Toffelmire
I have coded question 3, but am getting the following error from the
given code
class Umpire {
// YOU MAY ADD MEMBERS
Umpire( Player::Players &players );
void start();
};
error C2027: use of undefined type 'Player'
error C2061: syntax error : identifier 'Players'
I currently forward declare the Player class, but cannot seem to
forward declare the Players structure so that this works.
If I were allowed to modify this code, I believe I have found a work
around, but "you may NOT change or remove from any of the GIVEN
interface declarations or add any additional public declarations".
What am I supposed to do with these errors?
Thanks for any help,
Ian Toffelmire
As it happens, I had already placed those functions under public (the
only relevant change I can find from the newest updates).
I have also already friended relevant classes, so Umpire has access
(or is supposed to have access) to Varray (though oddly not its
members, apparently, which I think makes sense since Varray is a
substructure of Player).
The error indicates that the Umpire class does not even have access to
the Player class (that is, when the Umpire class's code is being
compiled, the definition of Player seems to not exist), which doesn't
make sense to me because of the includes and forward declarations I
have.
I have a .h and a .cc file for each part of the program (except
PRNG.cc and q3driver.h do not exist).
I have been using Microsoft Visual C++ 2010 for this assignment, so I
sent the code over to a linux environment and g++ gave me this error
(many times in a row):

./q3umpire.h:13: error: a class-key must be used when declaring a
friend
./q3umpire.h:13: error: friend declaration does not name a class or
function

I would appreciate any help on any of these error messages.
Jeremy Roman
2011-07-01 23:28:45 UTC
Permalink
Post by Ian Toffelmire
As it happens, I had already placed those functions under public (the
only relevant change I can find from the newest updates).
I have also already friended relevant classes, so Umpire has access
(or is supposed to have access) to Varray (though oddly not its
members, apparently, which I think makes sense since Varray is a
substructure of Player).
The error indicates that the Umpire class does not even have access to
the Player class (that is, when the Umpire class's code is being
compiled, the definition of Player seems to not exist), which doesn't
make sense to me because of the includes and forward declarations I
have.
I have a .h and a .cc file for each part of the program (except
PRNG.cc and q3driver.h do not exist).
I have been using Microsoft Visual C++ 2010 for this assignment, so I
sent the code over to a linux environment and g++ gave me this error
./q3umpire.h:13: error: a class-key must be used when declaring a
friend
./q3umpire.h:13: error: friend declaration does not name a class or
function
I would appreciate any help on any of these error messages.
Be careful about how much you discuss the nature of your solution; I'm
not sure how much you are allowed to say on the design of your access
controls.

Your error message is probably occurring because you are doing something
like this:

friend SomeClassName;

when you should be doing:

friend class SomeClassName;

If you still cannot resolve your issue, you may need to discuss this
with the tutor or one of the instructors, who are (unlike me and other
classmates) authorized to look at your code.
--
Jeremy Roman
Student, Computer Science
University of Waterloo
Loading...