Jump to content

Abstract type: Difference between revisions

added Nemerle
No edit summary
(added Nemerle)
Line 1,012:
B:new() -- Error: B is abstract
BB:new() -- Okay: BB is not abstract</lang>
 
=={{header|Nemerle}}==
<lang Nemerle>using System.Console;
 
namespace RosettaCode
{
abstract class Fruit
{
abstract public Eat() : void;
abstract public Peel() : void;
virtual public Cut() : void // an abstract class con contain a mixture of abstract and implemented methods
{ // the virtual keyword allows the method to be overridden by derivative classes
WriteLine("Being cut.");
}
}
interface IJuiceable
{
public Juice() : void; // interfaces contain only the signatures of methods
}
class Orange : Fruit, IJuiceable
{
public override Eat() : void // implementations of abstract methods need to be marked override
{
WriteLine("Being eaten.");
}
public override Peel() : void
{
WriteLine("Being peeled.");
}
public Juice() : void
{
WriteLine("Being juiced.");
}
}
}</lang>
 
=={{header|NetRexx}}==
Cookies help us deliver our services. By using our services, you agree to our use of cookies.