Jump to content


Evil C++ Errors


2 replies to this topic

#1 greywolf

greywolf

    The Wanderer

  • Members
  • PipPipPipPipPipPip
  • 684 posts

Posted 08 November 2006 - 07:08 PM

Ok, so after finally getting around to experimenting with C++ again and trying to create a Gamebiz-type clone, I've already run into some problems. I'm making a class 'game', and declaring all the variable members in it, as is normal (or so I think).

class game
{
	public: 
		int genre = 0;
		int graphics = 0;
		int story = 0;
		int GUI = 0;
		int originality = 0;
		int requirements = 0;	
};


But when I compile it, the debugger gives me all sorts of junk about "error C2864: 'game::genre' : only static const integral data members can be initialized within a class." It gives that same error for all the ints I declared in that class. This code is in the header file, and I'm using Microsoft's Visual C++ Express, if that makes any difference. Any ideas?

#2 Qbix

Qbix

    AR-coholic

  • Members
  • PipPipPipPipPipPip
  • 605 posts

Posted 09 November 2006 - 07:08 AM

as the error is pointing out.
you aren't allowed to add the
=0
to your variables (in the class definition)
If you don't understand why I suggest you read something more on classes.
Hint: you need to do that in your constructor

#3 greywolf

greywolf

    The Wanderer

  • Members
  • PipPipPipPipPipPip
  • 684 posts

Posted 09 November 2006 - 05:30 PM

Ah, thank you! Now to deal with the countless other errors...




Reply to this topic



  


Skin Designed By Evanescence at IBSkin.com