Public Group

# Class errors

This topic is 4107 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Hello all, I'm getting trouble with a class that I just added:
extern class c_piece
{
public:

int rotation;
void rotate()
{
rotation++;
}
int x;
int y;
int arr_size [4] [4];
};
This is the error:
Quote:
 error: a storage class can only be specified for objects and functions
Here is all of the code (with Xcode project build if you have a Mac :)): Link to files Any ideas?

##### Share on other sites
Never used this language before... but...
Just based on the error, it sounds a lot like you'll have to change the extern keyword, or else get rid of your fields (int x, y, arr_size)

This is just a total guess, hope it helps.

##### Share on other sites
Quote:
 Original post by BubbaColaNever used this language before... but...Just based on the error, it sounds a lot like you'll have to change the extern keyword, or else get rid of your fields (int x, y, arr_size)This is just a total guess, hope it helps.

Good guess. That extern thing wasn't supposed to be there, though. It has a different error without the extern there, referencing to Other_functions.cpp, saying that basically the class is not defined there. Soooo... how do I get it to be defined in both files?

##### Share on other sites
It looks like you're trying to use the global variable curr_piece in Other_Functions.cpp. You need to add this line to sdl_t002.h

extern c_piece curr_piece;

You need to use the extern keyword for global instances of a class, but not on the class definition itself.

##### Share on other sites
Ok, so what you wrote got me to thinking, and I got it fixed. The problem was in that I didn't properly define something directly above where I defined the class. Thanks for the help!

EDIT: Meh, I posted after pi_equals_3, but I came to the same conclusion as him. Thanks!

1. 1
2. 2
3. 3
4. 4
Rutin
15
5. 5

• 13
• 26
• 10
• 11
• 9
• ### Forum Statistics

• Total Topics
633724
• Total Posts
3013556
×