Hi,
I currently have a class called DefinedTest which relates to a set of
tests I perform. But there are two Test states, those that are defined
and those that are not. I'd therefore like to have two classes
instead, Test and DefinedTest with the former storing either Defined
or non-Defined Tests and the latter only defined tests.
The distinction between the two classes in terms of members is very
simple. A defined test has a file on the local computer which exists,
the undefined test has a file which is not present on the local
computer.
I therefore wish to have something like this -
DefinedTest
{
ExistingFile file;
}
Test
{
File file;
}
ExistingFile and File are classes I have writen also. ExistingFile is
inherited from File with the only difference being that ExistingFile's
constructor and set check that the file exists locally. If not, an
exception is called. I use this class a lot in my code as it confirms
that the file exists when the object is constructed and I therefore
don't have to worry about files being missing - of course the file
could be deleted after the constructer is called, but this is not an
issue for me.
So here's my question. DefinedTest and Test are identical in terms of
members, all except for the file member. Is it possible for me to have
DefinedTest as being inherit from Test? How would you implement this?
Thanks,
Barry