Making Handle a Superclass

8 visualizaciones (últimos 30 días)
Benjamin
Benjamin el 20 de Dic. de 2013
Comentada: Benjamin el 20 de Dic. de 2013
I am trying to make a handle class, but I keep getting an error which says "The class 'handle' is not a superclass of class 'Go_board', as required to invoke a superclass constructor or method."
Here is the code I am trying for my class:
classdef Go_board < handle
properties
Board
end
methods
function obj=Go_board(size)
A = Go_cell();
obj.Board = repmat(A, size);
end
end
end
Also, here is the code for by Go_cell class:
classdef Go_cell
properties
state = char('e');
checked = logical(0);
end
end
I don't understand what is wrong because I thought "< handle" made handle a superclass of Go_board. I appreciate any help.
  1 comentario
Jacob Halbrooks
Jacob Halbrooks el 20 de Dic. de 2013
It looks like you've subclassed from handle correctly. What code do you execute that results in an error?
Also, you might consider using false instead of logical(0), and just 'e' instead of char('e').

Iniciar sesión para comentar.

Respuesta aceptada

Sean de Wolski
Sean de Wolski el 20 de Dic. de 2013
Run:
clear;
clear classes;
To make sure that any old instances of your class are gone.
If the error still appears, then make sure you're using the latest version of the class:
which -all Go_board
Writing a game while on vacation? :)
  2 comentarios
Sean de Wolski
Sean de Wolski el 20 de Dic. de 2013
Editada: Sean de Wolski el 20 de Dic. de 2013
My guess is it's the second one, i.e. you have two versions of the class. Your class doesn't appear to call the superclass constructor.
Benjamin
Benjamin el 20 de Dic. de 2013
Running "clear classes" was what worked. Thanks.
Yes, by brother challenged me to code a Go board over my break.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Construct and Work with Object Arrays en Help Center y File Exchange.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by