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

Saturday, November 11, 2017

C++ programming language part: 54 Scope Resolution with Overridden Members


Scope Resolution with Overridden Members

To access a base class member from a derived class, the scope resulation operator is used.  Attentively follow the following program.

Program 42_3
            //Scope resulation with overidden
            class furniture              //class defined
            {
              private:
              char color[10];
              int width,height;

              public:
              void data_in()
               {
              cout<<"Type color of bookshelf (red or blue?)\t";
               cin>>color;
               cout<<"Type width\t";
               cin>>width;
               cout<<"Type height\t";
               cin>>height;
               }

             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:
               void data_in()
             {
               furniture::data_in();       // Scope Resolution Operator
               cout<<"Type number of selves\t";
               cin>>self_no;
             }
             
               void data_out() //member function
             {
               furniture::data_out();     // Scope Resolution Operator
               cout<<" Number of selves are "<
            }
            };
            class chair:public furniture
            {
               private:
               int leg_no;                
              
               public:
               void data_in()      //member function
             {
               furniture::data_in();        // Scope Resolution Operator
               cout<<"Type number of legs\t";
               cin>>leg_no;
             }
             
               void data_out() //member function
             {
               furniture::data_out();       // Scope Resolution Operator
               cout<<" Number of legs are "<
             }
             };

            void main()
            {
             bookshelf A;                // A,B is called object
             chair B;
             A.data_in();                //would be k->data_in() if pointer
             A.data_out();
             B.data_in();                 //would be k->data_in() if pointer
             B.data_out();

            }




Part- 86 assign the content of twostring



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