F
Francesc Benavent
Hi all, I'm trying to implement an interface, shared for different
classes, with a method that must return an object belonging to the
same class that implements the interface.
May be an example should be clearer:
==============================
public interface IVector
{
[***] Addition([***]);
}
public class BinaryVector : IVector
{
BinaryVector Addition (BinaryVector)
{
}
}
public class RealVector : IVector
{
RealVector Addition (RealVector)
{
}
}
==============================
That is:
1) Define IVector.
2) if BinaryVector implements the IVector interface, it MUST have a
method that receives a BinaryVector and returns a BinaryVector.
3) if RealVector implements the IVector interface, it MUST have a
method that receives a RealVector and returns a RealVector.
QUESTION: How I must define this interface at [***]?
Please, any suggestions or correction would be welcomed,
Francesc
Note: At first I tried to define an abstract class Vector from others
inherited, but I thought that an Interface would be better.
classes, with a method that must return an object belonging to the
same class that implements the interface.
May be an example should be clearer:
==============================
public interface IVector
{
[***] Addition([***]);
}
public class BinaryVector : IVector
{
BinaryVector Addition (BinaryVector)
{
}
}
public class RealVector : IVector
{
RealVector Addition (RealVector)
{
}
}
==============================
That is:
1) Define IVector.
2) if BinaryVector implements the IVector interface, it MUST have a
method that receives a BinaryVector and returns a BinaryVector.
3) if RealVector implements the IVector interface, it MUST have a
method that receives a RealVector and returns a RealVector.
QUESTION: How I must define this interface at [***]?
Please, any suggestions or correction would be welcomed,
Francesc
Note: At first I tried to define an abstract class Vector from others
inherited, but I thought that an Interface would be better.