Oberon Community Platform Forum
November 18, 2017, 03:29:40 AM *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
News:
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: Object cannot implement a method?  (Read 2631 times)
hreba
Newbie
*
Posts: 14


« on: February 09, 2009, 10:02:54 PM »

The following program
Code:
module Main;

definition Graphical;
  var x, y: integer;
  procedure MoveTo (newX,newY: integer);
end Graphical;

type GraphObj = object implements Graphical
  procedure MoveTo (newX,newY: integer);
  begin x:= newX;  y:= newY
  end MoveTo;
end GraphObj;

end Main.
gets me the error message

    [5,13] [0119] Type 'Zonnon.Main+GraphObj' already defines a method called 'MoveTo' with the same parameter types
    [9,13] [0259] (Location of symbol related to previous error)
[0213] Could not find a type named 'Graphical_mixed'

Is my deduction correct that an object cannot implement a method?
Logged
rmitin
Moderator
Newbie
*****
Posts: 22


« Reply #1 on: February 09, 2009, 11:02:31 PM »

You need to write explicitly that you want to override a particular method from a particular definition. In addition the method has to be public. The correct example would be:

Code:

module Main;

definition Graphical;
  var x, y: integer;
  procedure MoveTo (newX,newY: integer);
end Graphical;

type GraphObj = object implements Graphical
  procedure {public} MoveTo (newX,newY: integer) implements Graphical.MoveTo;
  begin x:= newX;  y:= newY
  end MoveTo;
end GraphObj;

end Main.
Logged
hreba
Newbie
*
Posts: 14


« Reply #2 on: February 10, 2009, 09:34:44 PM »

Thanks, this too is clear now.
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.21 | SMF © 2015, Simple Machines Valid XHTML 1.0! Valid CSS!