I get the following error:
Cannot implicitly convert type 'Factory.Stack.pArrayStack' to
'Factory.Stack.StackDefs.ImStack'
at compile time.
I thought perhaps there was a mismatch between the interface method
types and the actual implementation types, so I removed all methods
from both the interface and the implementation (pArrayStack ) but
still get the error. Here is the code with just one simple method
still declared and implemented.
Any ideas as to what causes the error?
For the following code samples, all classes are in the
"Factory.Stack" namespace
Here are the basic parts:
public class StackDefs
{
public interface ImStack
{
// void Push(object o);
// object Pop();
bool isEmpty();
}
public interface IStackFactory
{
ImStack CreateStack();
}
}
Then:
public class AbsFactory
{class ArrayStackFactory : StackDefs.IStackFactory
{
public StackDefs.ImStack CreateStack()
{
//Error occurs on the next line on the word "new"
return new pArrayStack();
}
}
And then:
public class pArrayStack
{
// declare some properties
//protected object[] data = new object[10];
protected int pointer= 0;
/**
* check whether this stack is empty
*/
public bool isEmpty()
{
return pointer == 0;
}
//Other methods commented out until error is resolved.
....................
}
I am relatively new to working with interfaces.
Thanks alot
Jeff