Q&A

  • Class내 정의된 procedure내에서 자신지정은?
초보라 잘 몰라서 물어요..



type

TMy=class

i:byte;

procedure init(you:TMy);

end;

var My,Your:TMy;



procedure TMy.init;

begin

i:=0;

end;

procedure TMy.A1(you:TMy=nil);

begin

if you=nil then you:=(TMy); <==

...

you.i:=10;

end;



procedure A1;

var n:byte;

begin

My:=TMy.Create; My.init;

Your:=TMy.Create; Your.init;

My.A1();

My.A1(You);

end;

A1에 인자가 없으면 My.i:=10 이고, 있으면 인자.i:=10이고 싶은데 어떻하져..??



2  COMMENTS
  • Profile
    밥벌레 2000.07.14 16:58
    한상훈 wrote:

    > 초보라 잘 몰라서 물어요..

    >

    > type

    > TMy=class

    > i:byte;

    > procedure init(you:TMy);

    > end;

    > var My,Your:TMy;

    >

    > procedure TMy.init;

    > begin

    > i:=0;

    > end;

    > procedure TMy.A1(you:TMy=nil);

    > begin

    > if you=nil then you:=(TMy); <==

    > ...

    > you.i:=10;

    > end;

    >

    > procedure A1;

    > var n:byte;

    > begin

    > My:=TMy.Create; My.init;

    > Your:=TMy.Create; Your.init;

    > My.A1();

    > My.A1(You);

    > end;

    > A1에 인자가 없으면 My.i:=10 이고, 있으면 인자.i:=10이고 싶은데 어떻하져..??

    >



    if you=nil then you := Self;



    이거 물어보신거 맞죠?? 질문 해석이 무지하게 힘들었음..^^

  • Profile
    한상훈 2000.07.15 11:57
    밥벌레 wrote:

    > 한상훈 wrote:

    > > 초보라 잘 몰라서 물어요..

    > >

    > > type

    > > TMy=class

    > > i:byte;

    > > procedure init(you:TMy);

    > > end;

    > > var My,Your:TMy;

    > >

    > > procedure TMy.init;

    > > begin

    > > i:=0;

    > > end;

    > > procedure TMy.A1(you:TMy=nil);

    > > begin

    > > if you=nil then you:=(TMy); <==

    > > ...

    > > you.i:=10;

    > > end;

    > >

    > > procedure A1;

    > > var n:byte;

    > > begin

    > > My:=TMy.Create; My.init;

    > > Your:=TMy.Create; Your.init;

    > > My.A1();

    > > My.A1(You);

    > > end;

    > > A1에 인자가 없으면 My.i:=10 이고, 있으면 인자.i:=10이고 싶은데 어떻하져..??

    > >

    >

    > if you=nil then you := Self;

    >

    > 이거 물어보신거 맞죠?? 질문 해석이 무지하게 힘들었음..^^



    감사합니다.. 저두 제의문을 표현하는데 무지 힘들었음.. ^^