You are on page 1of 2

report z745oops13.

Parameters to
instance constructor
class emp definition.
public section.
methods : constructor importing x type i optional y type c optional,

m2.
*
class-methods class_constructor importing x type i. "cannot
contain parameters
protected section.
data : empno type i,
ename(20) type c.
endclass.
class emp implementation.
method constructor.
empno = x.
ename = y.
endmethod.
method m2.
write :/ empno,ename.
endmethod.
endclass.
start-of-selection.
write :/ 'First object without passing parameters to instance con
st...'.
data ob1 type ref to emp.
create object ob1.
call method ob1->m2.
uline.
parameters : p_x type i,
p_y(20) type c.

write :/ 'Second object passing parameters to instance const...'.


data ob2 type ref to emp.

create object ob2


exporting
x = p_x
y = p_y.
call method ob2->m2.
uline.
write :/ 'Third object passing only ename parameter to instance c
onst...'.
data ob3 type ref to emp.
create object ob3
exporting
*
x = p_x
y = p_y.
call method ob3->m2.

You might also like