• Advertisement
Sign in to follow this  

Class errors

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

If you intended to correct an error in the post then please contact us.

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 this post


Link to post
Share on other sites
Advertisement
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 this post


Link to post
Share on other sites
Quote:
Original post by BubbaCola
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.


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 this post


Link to post
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 this post


Link to post
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!

adam_o

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

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement