Brian
2010-10-20 19:23:15 UTC
I have Delphi 6, so I can't use the parameterized generics. So, I just
tried stuffing some objects into a list. The objects implement the
IRecyclable interface, but when try to use the code, it gives the
following error.
"Project1.exe raised exception class EPrivilege with message
'Priveleged Instruction'"
It seems that I ought to be able to stuff a list with a set of objects
that implement an interface, cast
each object to that interface and access it. What am I doing wrong?
code based upon the interface example at the following site:
http://www.delphibasics.co.uk/Article.asp?Name=Interface
brian
ListStuff := TList.Create;
// Instantiate our bike and car objects
mumsBike := TBicycle.Create(false, 24);
ListStuff.Add(mumsBike);
dadsCar := TCar.Create('Nissan bluebird');
ListStuff.Add(dadsCar);
for i := 0 to ListStuff.Count - 1 do
if (IRecyclable(ListStuff[i])).isRecyclable then
ShowMessage('Recyclable');
tried stuffing some objects into a list. The objects implement the
IRecyclable interface, but when try to use the code, it gives the
following error.
"Project1.exe raised exception class EPrivilege with message
'Priveleged Instruction'"
It seems that I ought to be able to stuff a list with a set of objects
that implement an interface, cast
each object to that interface and access it. What am I doing wrong?
code based upon the interface example at the following site:
http://www.delphibasics.co.uk/Article.asp?Name=Interface
brian
ListStuff := TList.Create;
// Instantiate our bike and car objects
mumsBike := TBicycle.Create(false, 24);
ListStuff.Add(mumsBike);
dadsCar := TCar.Create('Nissan bluebird');
ListStuff.Add(dadsCar);
for i := 0 to ListStuff.Count - 1 do
if (IRecyclable(ListStuff[i])).isRecyclable then
ShowMessage('Recyclable');