• <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>
            Impossible is nothing  
              愛過知情重醉過知酒濃   花開花謝終是空   緣份不停留像春風(fēng)來又走   女人如花花似夢
            公告
            日歷
            <2006年4月>
            2627282930311
            2345678
            9101112131415
            16171819202122
            23242526272829
            30123456
            統(tǒng)計(jì)
            • 隨筆 - 8
            • 文章 - 91
            • 評(píng)論 - 16
            • 引用 - 0

            導(dǎo)航

            常用鏈接

            留言簿(4)

            隨筆分類(4)

            隨筆檔案(8)

            文章分類(77)

            文章檔案(91)

            相冊

            搜索

            •  

            最新評(píng)論

            閱讀排行榜

            評(píng)論排行榜

             
            1 下面程序有什么錯(cuò)誤:
            class base{
            private: int i;
            public: base(int x){i=x;}
            };
            class derived: public base{
            private: int i;
            public: derived(int x, int y) {i=x;}
            void printTotal() {int total = i+base::i;}
            };



            2. Assume you have a class like

            class erp
            {
            HR* m_hr;
            FI* m_fi;
            public:
            erp()
            {
            m_hr = new HR();
            m_fi = new FI();
            }
            ~erp()
            {
            }
            };

            if "new FI()" failed in the constructor, how can you detect this problem and
            release the properly allocated member pointer m_hr?

            3. Check the class and variable definition below:

            #include <iostream>
            #include <complex>
            using namespace std;
            class Base
            {
            public:
            Base() { cout<<"Base-ctor"<<endl; }
            ~Base() { cout<<"Base-dtor"<<endl; }
            virtual void f(int) { cout<<"Base::f(int)"<<endl; }
            virtual void f(double) {cout<<"Base::f(double)"<<endl; }
            virtual void g(int i = 10) {cout<<"Base::g()"<<i<<endl; }
            };

            class Derived: public Base
            {
            public:
            Derived() { cout<<"Derived-ctor"<<endl; }
            ~Derived() { cout<<"Derived-dtor"<<endl; }
            void f(complex<double>) { cout<<"Derived::f(complex)"<<endl; }
            virtual void g(int i = 20) {cout<<"Derived::g()"<<i<<endl; }
            };

            Base b;
            Derived d;

            Base* pb = new Derived;
            Select the correct one from the four choices:
            Cout<<sizeof(Base)<<endl;
            A. 4 B.32 C.20 D.Platform-dependent
            Cout<<sizeof(Base)<<endl;
            A. 4 B.8 C.36 D.Platform-dependent
            pb->f(1.0);
            A.Derived::f(complex) B.Base::f(double)
            pb->g();
            A.Base::g() 10 B.Base::g() 20
            C.Derived::g() 10 D.Derived::g() 20

            4.Implement the simplest singleton pattern(initialize if necessary).

            5.Name three sort algorithms you are familiar with. Write out the correct
            order by the average time complexity.

            6.Write code to sort a duplex direction linklist. The node T has overridden
            the comparision operators.


            7.Below is usual way we find one element in an array:

            const int *find1(const int* array, int n, int x)
            {
            const int* p = array;
            for(int i = 0; i < n; i++)
            {
            if(*p == x)
            {
            return p;
            }
            ++p;
            }
            return 0;
            }

            In this case we have to bear the knowledge of value type "int", the size of
            array, even the existence of an array. Would you re-write it using template
            to eliminate all these dependencies?
            posted on 2006-04-12 22:35 笑笑生 閱讀(1475) 評(píng)論(2)  編輯 收藏 引用 所屬分類: STL/BOOST
            評(píng)論:
            • # re: sap的幾道筆試題目(轉(zhuǎn))  任我行 Posted @ 2006-04-13 08:47
              1.
              public: derived(int x, int y) {i=x;}
              //derived(int x, int y):base(y){i=x;}
              void printTotal() {int total = i+#base::i#;}
              2.
              try{
              m_fi = new FI();
              }
              catch(bad_alloc &){
              delete m_hr;
              }

              3.前兩題題目重復(fù)吧。
              Cout<<sizeof(Base)<<endl; //32
              A. 4 B.32 C.20 D.Platform-dependent
              Cout<<sizeof(Base)<<endl;
              A. 4 B.8 C.36 D.Platform-dependent
              3.3
              pb->f(1.0); //Base::f(double)
              pb->g();//Derived::g()20  回復(fù)  更多評(píng)論   

            • # re: sap的幾道筆試題目(轉(zhuǎn))  tuesday Posted @ 2006-04-13 19:39
              第二題可以這樣做
              template<class T>
              class PWrap
              {
              T* ptr;
              PWrap() { ptr = new T;}
              ~PWrap() {delete ptr;}
              };

              class erp
              {
              PWrap<HR> m_hr;
              PWrap<FI> m_fi;
              };  回復(fù)  更多評(píng)論   

             
            Copyright © 笑笑生 Powered by: 博客園 模板提供:滬江博客
            精品久久久久久久久久中文字幕| 久久精品国产亚洲AV忘忧草18| 久久久精品一区二区三区| 久久综合久久综合久久| 久久精品视屏| 婷婷久久香蕉五月综合加勒比| 国产成人精品久久一区二区三区av| 国产精品久久久久久久久久免费| 久久伊人五月丁香狠狠色| 久久精品中文无码资源站| 国内精品久久久久国产盗摄| 久久久久久久精品妇女99| 国产精品久久永久免费| 亚洲国产婷婷香蕉久久久久久| 久久九九精品99国产精品| 亚洲国产成人乱码精品女人久久久不卡 | 99久久综合狠狠综合久久| 亚洲精品无码久久久久久| 狠狠人妻久久久久久综合| 久久久无码精品亚洲日韩按摩 | 国产精品久久久久AV福利动漫| 久久综合色区| 亚洲国产精品一区二区久久| AV无码久久久久不卡蜜桃| 香蕉99久久国产综合精品宅男自 | 亚洲AV日韩AV永久无码久久| 久久久精品日本一区二区三区| 久久久久久人妻无码| 97久久国产综合精品女不卡 | 亚洲欧美日韩久久精品| 久久精品三级视频| 国产午夜精品理论片久久| 国产精品一久久香蕉产线看| 久久精品国产亚洲av影院| 国产A级毛片久久久精品毛片| 久久久午夜精品| 久久国产劲爆AV内射—百度| 久久伊人五月丁香狠狠色| 中文精品久久久久人妻| 久久天天躁狠狠躁夜夜躁2014| 国产精品久久久久蜜芽|