know yourselves. information, computer, 7 wonders, various.

Saturday, November 11, 2017

C++ programming language part: 55 Base Class Initialization


Base Class Initialization


In the following program, the bookself class is inherited from the furniture. Hence, an object of the bookself class includes the member of the furniture class. So, the bookself class constructor must initialize not only its member, but also the base class member. to initialize the member of furniture class, the constructir of the furniture class before the bookself class data members are initialized. keep it mind that when an object of derived class is created, the base class constructor is executed before the derived class constructor. Destructors are executed in the reverse order.

Program 42_4
            //inherit.demo
             //Scope resulation with overidden
             class furniture             //class defined
{private:
            int color;
            int width,height;

            public:
            furniture()        // dafult constructor
{ color=width=height=0;}
             furniture(int C,int W,int H)     // constructor
                { color=C;
                  width=W;
                  height=H;  }

             void data_out()
            {cout<<" The color is "<
             cout<<" The width is "<
             cout<<" The height is "<
             };
            class bookshelf:public furniture
            {  private:
               int self_no;               // member data
               public:
               bookshelf(int S,int C,int W,int H):furniture(C,W,H)
           {  self_no=S;  }
           
void data_out()
             {furniture::data_out();     // Scope Resolution Operator
               cout<<" Number of selves are "<
            };
            void main()
            {bookshelf A(5,2,7,8);             // A is called object

             A.data_out(); }




Part- 86 assign the content of twostring



জ্ঞানকোষ প্রকাশনী
৩৮/২-ক, বাংলাবাজার (২য় তলা), ঢাকা।
       ফোনঃ ৭১১৮৪৪৩, ৮১১২৪৪১, ৮৬২৩২৫১.         
                                                     
কলকাতায় পরিবেশক/প্রাপ্তিস্থান
রিতা ইন্টারন্যাশনাল
৩৬, পি.এন. ব্যানার্জি রোড, কলকাতা
ফোনঃ ২৫১৩৮৩৫৯, ৯৮৩০৪৩৯৬৭৯, +৯১৯৮৩০৪৩৯৬৭৯


C++ programming language part: 56 Multiple Inheritance


Multiple Inheritance


It is possible for a derived class to inherit two or more base class. A familiar example of multiple inheritence is child inheriting the characteristics  of the parants.

Program 43_1
            class first_base           // base class defined
            {
              protected:
              int p1;       // to get it from derived class
             
              public:
              void data_out1()
               {
               cout<<" The verible of first base class is "<
               }
            };
              class second_base                  //base class defined
            {
              protected:
              int p2;       // to get it from derived class
             
              public:
              void data_out2()
               {
               cout<<" The verible of second base class is "<
               }
            };          // here are two base class named A & B

              // inherit multiple base class
              class derived:public first_base,public second_base     // this is derived class named derived
              {         
              public:
              void data_get(int x,int y)
            {
                  p1=x;
                  p2=y;
                }
            };        

             void main()
             { derived K;    // K is called object
               K.data_get(25,50);
               K.data_out1();
               K.data_out2();  }


Exercise: Write a program to use three or more base class for a derived class.




Part- 86 assign the content of twostring


জ্ঞানকোষ প্রকাশনী
৩৮/২-ক, বাংলাবাজার (২য় তলা), ঢাকা।
       ফোনঃ ৭১১৮৪৪৩, ৮১১২৪৪১, ৮৬২৩২৫১.         
                                                     
কলকাতায় পরিবেশক/প্রাপ্তিস্থান
রিতা ইন্টারন্যাশনাল
৩৬, পি.এন. ব্যানার্জি রোড, কলকাতা
ফোনঃ ২৫১৩৮৩৫৯, ৯৮৩০৪৩৯৬৭৯, +৯১৯৮৩০৪৩৯৬৭৯