Code crashes in v45c but was working in 45b

Monkey Forums/Monkey Programming/Code crashes in v45c but was working in 45b

c.k.(Posted 2011) [#1]
Don't know how this duped, but there ya go. I need to be able to delete posts. :)


c.k.(Posted 2011) [#2]
I get this error when trying to run a program I'm developing:

C:/myprog/screen_stats.monkey<7> : Error : Can't create instance of class StatsScreen due to abstract method Method Screen.Update:Void().
Error in compilation!

Here's the code:




muddy_shoes(Posted 2011) [#3]
I assume that the Screen class is Abstract and has the Update method declared as an abstract method. That means that you have to provide an implementation in any class that extends Screen.

That's not a crash, by the way. It's a compilation error.


Jesse(Posted 2011) [#4]
when you create abstract methods, that method has to be implemented in the extended class. it's something that wasn't working on previous versions of monkey and finally got fixed.


c.k.(Posted 2011) [#5]
Oh, so, basically, I need to create an Update() method for StatsScreen?


therevills(Posted 2011) [#6]
Yes...

If you look in framework.monkey, the Screen class is this:

Class Screen Abstract
	Field name$ = ""
	
	Method PreStart:Void()
		game.currentScreen = self
		Start()
	End
	
	Method Start:Void() Abstract
	
	Method Render:Void() Abstract
	
	Method Update:Void() Abstract

...


If you extend this class you must have a Start, Render and Update method in your own class.


c.k.(Posted 2011) [#7]
Thanks, therevills! I must have skipped class on that day. :)