日本a√视频在线,久久青青亚洲国产,亚洲一区欧美二区,免费g片在线观看网站

        <style id="k3y6c"><u id="k3y6c"></u></style>
        <s id="k3y6c"></s>
        <mark id="k3y6c"></mark>
          
          

          <mark id="k3y6c"></mark>

          新聞中心

          EEPW首頁 > 嵌入式系統(tǒng) > 設(shè)計(jì)應(yīng)用 > C++構(gòu)造函數(shù)與析構(gòu)函數(shù)的使用方法

          C++構(gòu)造函數(shù)與析構(gòu)函數(shù)的使用方法

          作者: 時(shí)間:2016-12-01 來源:網(wǎng)絡(luò) 收藏
          構(gòu)造函數(shù),是一種特殊的方法 。主要用來在創(chuàng)建對象時(shí)初始化對象, 即為對象成員變量賦初始值,總與new運(yùn)算符一起使用在創(chuàng)建對象的語句中 。特別的一個(gè)類可以有多個(gè)構(gòu)造函數(shù) ,可根據(jù)其參數(shù)個(gè)數(shù)的不同或參數(shù)類型的不同來區(qū)分它們 即構(gòu)造函數(shù)的重載。

          析構(gòu)函數(shù)(destructor) 與構(gòu)造函數(shù)相反,當(dāng)對象脫離其作用域時(shí)(例如對象所在的函數(shù)已調(diào)用完畢),系統(tǒng)自動(dòng)執(zhí)行析構(gòu)函數(shù)。

          #include
          class animal
          {
          public:
          animal()
          {
          cout<<"hello"<}
          ~animal()
          {
          cout<<"析構(gòu)函數(shù)"<}
          void animal1();

          本文引用地址:http://yuyingmama.com.cn/article/201612/324420.htm

          };
          void animal::animal1 () //構(gòu)造函數(shù)
          {
          int box[3],i,sum=0; //sun記得賦初值
          cout<<"請輸入三個(gè)數(shù)"< for(i=0;i<3;i++)
          {
          cin>>box[i];
          sum=box[i]+sum;
          }
          cout<}
          int main()
          {
          animal sh;
          sh.animal1 ();
          return 0;
          }



          評論


          技術(shù)專區(qū)

          關(guān)閉