My only ? is when I'm passing the object type, the function doesn't understand what the "type" is for example
MAIN Program
- Code: Select all
program experimentwobject;
{$APPTYPE CONSOLE}
uses
SysUtils,
OptConsts in 'OptConsts.pas',
Unit2 in 'Unit2.pas';
var
MyFirst: OptTerms;
begin
Myfirst := OptTerms.Create;
MyFirst.ShowInfo;
WriteSomething(MyFirst);
readln;
MyFirst.Free;
end.
OptConsts (My class)
- Code: Select all
unit OptConsts;
interface
type
OptTerms = class
const COVERAGE: integer = 10;
const COVERAGE2: integer = 20;
const COVERAGE3: integer = 30;
procedure ShowInfo;
end;
implementation
Procedure OptTerms.ShowInfo;
begin
writeln(OptTerms.COVERAGE);
writeln(OptTerms.COVERAGE2);
writeln(OptTerms.COVERAGE3);
end;
end.
Unit2 (This is where i'm trying to pass a type OptTerms Paramter, and the function doesn't understand what a OptTerms Type is
- Code: Select all
unit Unit2;
interface
procedure WriteSomething (x: OptTerm);
implementation
procedure WriteSomething (x: OptTerm);
begin
writeln(x.COVERAGE);
end;
end.
So my ? is, in order to use the new object type can they only be used in the main program (where they are definied) and only the Unit/class in which they are defined. If so, that leaves me little use for OOP because I would like to pass a type OptTerms to many other fucntions, only problem is those functions don't understand what an OptTerms type is.
Thanks