<small id='QOeahHlGC2'></small> <noframes id='tCPb'>

  • <tfoot id='ZwjL'></tfoot>

      <legend id='Palzi'><style id='GdjgO6L0WQ'><dir id='pcU5MFLNdi'><q id='D0bSpNuaC'></q></dir></style></legend>
      <i id='9kYjWnA3N'><tr id='Zpy1x'><dt id='DxYc2'><q id='5GHFUL0M'><span id='W2Ymk0p'><b id='5HDFu7wOQ'><form id='wVMr'><ins id='ly9tqAV2'></ins><ul id='J0SB'></ul><sub id='IR6PB9c3Wz'></sub></form><legend id='keVUGL'></legend><bdo id='cwKZmJ'><pre id='9fcL'><center id='fV1SJL'></center></pre></bdo></b><th id='rCpoI'></th></span></q></dt></tr></i><div id='bBigc'><tfoot id='SfPMZEqDj8'></tfoot><dl id='dHohSFR'><fieldset id='Z25QcexvhP'></fieldset></dl></div>

          <bdo id='ncAp7V'></bdo><ul id='3ARDZJ'></ul>

          1. <li id='MtQYp'></li>
            登陆

            C言语函数指针模仿面向对象

            admin 2020-02-14 290人围观 ,发现0个评论

            界说一个Boy结构体,他包括两个函数指针的成员

            typedef struct
            {
            int age;
            void (*grow)();
            voiC言语函数指针模仿面向对象d (C言语函数指针模仿面向对象*print)();
            }Boy;得意生活

            void myGrow(Boy *boy)

            {

            boy->age++;

            }

            void myPrint(Boy *boy)

            {

            printf("age=%d\n",boy->age);

            }

            int main()

            {

            Boy boy1 = {14, myGrow, myPrint};

            Boy boy2 = {10, myGrow, myPrint};

            bC言语函数指针模仿面向对象oy1.print(&boy1);

            boy2.print(&boy2);

            boy1.grow(&boy1);

            boy2.grow(&boy2);

            boy1.print(&boy1);

            boy2.print(&boy2);

            }

            请关注微信公众号
            微信二维码
            不容错过
            Powered By Z-BlogPHP