Anonymous user
Function definition: Difference between revisions
m
→{{header|IWBASIC}}
Line 617:
=={{header|IWBASIC}}==
<lang IWBASIC>
'1. Not Object Oriented Program
DECLARE Multiply(N1:INT,N2:INT),INT
DEF A,B:INT
Line 629:
PRINT Multiply(A,B)
PRINT
'When compiled as a console only program, a press any key to continue is automatic.
CLOSECONSOLE
Line 634 ⟶ 636:
END
SUB Multiply(N1:INT,N2:INT),INT
DEF Product:INT
Line 643 ⟶ 645:
ENDSUB
'Can also be written with no code in the subroutine and just RETURN N1*N2.
'Not Object Oriented Program Using A Macro▼
----
▲'2. Not Object Oriented Program Using A Macro
$MACRO Multiply (N1,N2) (N1*N2)
Line 662 ⟶ 668:
END
----
'Object Oriented Program▼
▲'3. In An Object Oriented Program
CLASS Associate
'
DECLARE Associate
DECLARE _Associate
'***Multiply declared***
DECLARE Multiply(UnitsSold:UINT),UINT
'members
DEF m_Price:UINT
DEF m_UnitsSold:UINT
DEF m_SalesTotal:UINT
ENDCLASS
Line 677 ⟶ 686:
DEF Ass:Associate
m_UnitsSold=10
Ass.Multiply(10)▼
OPENCONSOLE
Line 685 ⟶ 696:
PRINT
CLOSECONSOLE
END
SUB Associate::Multiply(UnitsSold:UINT),UINT
m_SalesTotal=m_Price*UnitsSold
Line 701 ⟶ 710:
SUB Associate::_Associate()
ENDSUB
|