C++物件導向程式設計 類和物件提高篇 建構函式

czhaii發表於2012-08-28
//Page71 72 C++ 物件導向程式設計
                 #include                                 //
                 #include                               //
                 class  Calculator                                         //Calculator   計算器
                  {
                      private:                                                  //
                      int num1,num2,result;                           //
                      public:                                                  //
                      void  initialize( )                                   //initialize初始化
                       {
                         num1=10;                                          //
                         num2=20;                                          //
                        }
                      void add( )                                            //
                      {
                       result=num1+num2;                            //
                       }
                       void display( )                                      //
                      {
                      cout<                       }
                    };
                 void   main( )                                            //
                  {
                    Calculator c1;                                        //
                    c1.initialize( );                                       //
                    c1.add( );                                              //
                    c1.display( );                                         //
                   }
 
 
 

 




來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/27660822/viewspace-742102/,如需轉載,請註明出處,否則將追究法律責任。

相關文章