Object Oriented Programming Practice (Intake 41)

Question

Create 3 classes named base, derived1,derived2. Here base class is inherited by derived1 and derived2. now write a function named void_print() in the base class which will print the message “in the base class”. and then redefined void_print() function in both derived1 and derived2.

in progress 2
Ask me anything 1 week 23 Answers 158 views 0

Answers ( 23 )

  1. Name:Sanjara
    Id:166
    section:4

    #include
    using namespace std;

    class base{
    public:
    void print()
    {
    cout<<"IN THE BASE CLASS"<<endl;}
    };
    class derived1:public base{
    public:
    void print()
    {
    cout<<"IN THE BASE CLASS"<<endl;
    }
    };
    class derived2:public base{
    public:
    void print()
    {
    cout<<"IN THE BASE CLASS"<<endl;
    }
    };
    int main()
    {
    derived1 obj1;
    obj1.print();

    derived2 obj2;
    obj2.print();
    return 0;
    }

  2. name:Md. Emon Ali
    ID:154

    #include
    using namespace std;

    class base{
    public:
    void print()
    {
    cout<<"IN THE BASE CLASS"<<endl;}
    };
    class derived1:public base{
    public:
    void print()
    {
    cout<<"IN THE BASE CLASS"<<endl;
    }
    };
    class derived2:public base{
    public:
    void print()
    {
    cout<<"IN THE BASE CLASS"<<endl;
    }
    };
    int main()
    {
    derived1 obj1;
    obj1.print();

    derived2 obj2;
    obj2.print();
    return 0;
    }

  3. Name:Tabassum Mehrin Prova
    ID:177
    Sec:4
    #include
    using namespace std;

    class base{
    public:
    void print()
    {
    cout<<"IN THE BASE CLASS"<<endl;}
    };
    class derived1:public base{
    public:
    void print()
    {
    cout<<"IN THE BASE CLASS"<<endl;
    }
    };
    class derived2:public base{
    public:
    void print()
    {
    cout<<"IN THE BASE CLASS"<<endl;
    }
    };
    int main()
    {
    derived1 obj1;
    obj1.print();

    derived2 obj2;
    obj2.print();
    return 0;
    }

  4. Name:Shamima Akter Shimu id:18192103144 #include
    using namespace std;

    class base{
    public:
    void print()
    {
    cout<<"IN THE BASE CLASS"<<endl;}
    };
    class derived1:public base{
    public:
    void print()
    {
    cout<<"IN THE BASE CLASS"<<endl;
    }
    };
    class derived2:public base{
    public:
    void print()
    {
    cout<<"IN THE BASE CLASS"<<endl;
    }
    };
    int main()
    {
    derived1 obj1;
    obj1.print();

    derived2 obj2;
    obj2.print();
    return 0;
    }

  5. Name: Tamanna Tasnim
    ID:142

    #include
    using namespace std;

    class base
    {
    public:
    void print()
    {
    cout<<"IN THE BASE CLASS"<<endl;
    }
    };
    class derived1:public base
    {
    public:
    void print()
    {
    cout<<"IN THE BASE CLASS"<<endl;
    }
    };
    class derived2:public base
    {
    public:
    void print()
    {
    cout<<"IN THE BASE CLASS"<<endl;
    }
    };
    int main()
    {
    derived1 obj1;
    obj1.print();

    derived2 obj2;
    obj2.print();

    return 0;
    }

  6. Name:Asfack uddin nabil
    Id:173
    section:4

    #include
    using namespace std;

    class base{
    public:
    void print()
    {
    cout<<"IN THE BASE CLASS"<<endl;}
    };
    class derived1:public base{
    public:
    void print()
    {
    cout<<"IN THE BASE CLASS"<<endl;
    }
    };
    class derived2:public base{
    public:
    void print()
    {
    cout<<"IN THE BASE CLASS"<<endl;
    }
    };
    int main()
    {
    derived1 obj1;
    obj1.print();

    derived2 obj2;
    obj2.print();
    return 0;
    }

  7. ID:18192103139
    #include
    using namespace std;

    class base{
    public:
    void print()
    {
    cout<<"IN THE BASE CLASS"<<endl;}
    };
    class derived1:public base{
    public:
    void print()
    {
    cout<<"IN THE BASE CLASS"<<endl;
    }
    };
    class derived2:public base{
    public:
    void print()
    {
    cout<<"IN THE BASE CLASS"<<endl;
    }
    };
    int main()
    {
    derived1 obj1;
    obj1.print();

    derived2 obj2;
    obj2.print();
    return 0;
    }

  8. Name : Jahinur Islam
    Id: 18192103169

    #include
    using namespace std;

    class base{
    public:
    void print()
    {
    cout<<"IN THE BASE CLASS"<<endl;}
    };
    class derived1:public base{
    public:
    void print()
    {
    cout<<"IN THE BASE CLASS"<<endl;
    }
    };
    class derived2:public base{
    public:
    void print()
    {
    cout<<"IN THE BASE CLASS"<<endl;
    }
    };
    int main()
    {
    derived1 obj1;
    obj1.print();

    derived2 obj2;
    obj2.print();
    return 0;
    }

  9. ID- 18192103180

    #include
    using namespace std;

    class base{
    public:
    void print()
    {
    cout<<"IN THE BASE CLASS"<<endl;}
    };
    class derived1:public base{
    public:
    void print()
    {
    cout<<"IN THE BASE CLASS"<<endl;
    }
    };
    class derived2:public base{
    public:
    void print()
    {
    cout<<"IN THE BASE CLASS"<<endl;
    }
    };
    int main()
    {
    derived1 obj1;
    obj1.print();

    derived2 obj2;
    obj2.print();
    return 0;
    }

  10. name sabila Rahman
    ID:136

    #include
    using namespace std;

    class base{
    public:
    void print()
    {
    cout<<"IN THE BASE CLASS"<<endl;}
    };
    class derived1:public base{
    public:
    void print()
    {
    cout<<"IN THE BASE CLASS"<<endl;
    }
    };
    class derived2:public base{
    public:
    void print()
    {
    cout<<"IN THE BASE CLASS"<<endl;
    }
    };
    int main()
    {
    derived1 obj1;
    obj1.print();

    derived2 obj2;
    obj2.print();
    return 0;
    }

  11. Name:Shaminur Rahman
    Id:158
    section:4

    #include
    using namespace std;

    class base{
    public:
    void print()
    {
    cout<<"IN THE BASE CLASS"<<endl;}
    };
    class derived1:public base{
    public:
    void print()
    {
    cout<<"IN THE BASE CLASS"<<endl;
    }
    };
    class derived2:public base{
    public:
    void print()
    {
    cout<<"IN THE BASE CLASS"<<endl;
    }
    };
    int main()
    {
    derived1 obj1;
    obj1.print();

    derived2 obj2;
    obj2.print();
    return 0;
    }

  12. ID:18192103149
    #include
    using namespace std;

    class base{
    public:
    void print()
    {
    cout<<"IN THE BASE CLASS"<<endl;}
    };
    class derived1:public base{
    public:
    void print()
    {
    cout<<"IN THE BASE CLASS"<<endl;
    }
    };
    class derived2:public base{
    public:
    void print()
    {
    cout<<"IN THE BASE CLASS"<<endl;
    }
    };
    int main()
    {
    derived1 obj1;
    obj1.print();

    derived2 obj2;
    obj2.print();
    return 0;
    }

  13. Name: Md. Mintu Hossain
    ID: 17181103110

    #include
    using namespace std;

    class base
    {
    public:
    void void_print()
    {
    cout<<"in the base class"<<endl;
    }
    };
    class derived1:public base
    {
    public:
    void void_print()
    {
    cout<<"in the base class"<<endl;
    }
    };
    class derived2:public base
    {
    public:
    void Void_print()
    {
    cout<<"in the base class"<void_print();

    derived1 ob1;
    p=&ob1;
    p->void_print();

    derived2 ob2;
    p=&ob2;
    p->void_print();

    return 0;
    }

  14. Name: Rakibul Hasan Shafin
    ID: 18192103165
    Intake: 41
    Section:04
    #include
    using namespace std;

    class base
    {
    public:
    void void_print()
    {
    cout<<"in the base class"<<endl;
    }
    };
    class derived1:public base
    {
    public:
    void void_print()
    {
    cout<<"in the base class"<<endl;
    }
    };
    class derived2:public base
    {
    public:
    void Void_print()
    {
    cout<<"in the base class"void_print();

    derived2 ob2;
    p=&ob2;
    p->void_print();

    return 0;
    }

  15. Name: Rois Uddin Khan Emon
    Id: 18192103153
    Intake: 41
    section:4

    #include
    using namespace std;

    class base{
    public:
    void print()
    {
    cout<<"IN THE BASE CLASS"<<endl;}
    };
    class derived1:public base{
    public:
    void print()
    {
    cout<<"IN THE BASE CLASS"<<endl;
    }
    };
    class derived2:public base{
    public:
    void print()
    {
    cout<<"IN THE BASE CLASS"<<endl;
    }
    };
    int main()
    {
    derived1 obj1;
    obj1.print();

    derived2 obj2;
    obj2.print();
    return 0;
    }

  16. Name: Nigar Sultana Era
    Id: 175
    #include
    using namespace std;

    class base{
    public:
    void print()
    {
    cout<<"IN THE BASE CLASS"<<endl;}
    };
    class derived1:public base{
    public:
    void print()
    {
    cout<<"IN THE BASE CLASS"<<endl;
    }
    };
    class derived2:public base{
    public:
    void print()
    {
    cout<<"IN THE BASE CLASS"<<endl;
    }
    };
    int main()
    {
    derived1 obj1;
    obj1.print();

    derived2 obj2;
    obj2.print();
    return 0;
    }

  17. Name : MD Tayeb
    Intake: 41
    Sec: 4
    Id: 18192103169

    #include
    using namespace std;

    class base{
    public:
    void print()
    {
    cout<<"IN THE BASE CLASS"<<endl;}
    };
    class derived1:public base{
    public:
    void print()
    {
    cout<<"IN THE BASE CLASS"<<endl;
    }
    };
    class derived2:public base{
    public:
    void print()
    {
    cout<<"IN THE BASE CLASS"<<endl;
    }
    };
    int main()
    {
    derived1 obj1;
    obj1.print();

    derived2 obj2;
    obj2.print();
    return 0;
    }

  18. D.k.Shah Alam
    id:18192103 176
    sec-4

    #include
    using namespace std;
    class base{
    public:
    void void_print(){
    cout<< "In the base class"<<endl;
    }
    };
    class derived1: public base{
    public:
    void void_print(){
    cout<< "In the deriver1 class"<<endl;
    }
    };
    class derived2: public base{
    public:
    void void_print(){
    cout<< "In the deriver class"<<endl;
    }
    };
    int main()
    {
    base ob;
    ob.void_print();
    //derived1 ob2;
    //ob2.void_print();
    //derived2 ob3;
    //ob3.void_print();

    return 0;
    }

  19. name: Arup Raton Chowdhury
    ID:155

    #include
    using namespace std;

    class base{
    public:
    void print()
    {
    cout<<"IN THE BASE CLASS"<<endl;}
    };
    class derived1:public base{
    public:
    void print()
    {
    cout<<"IN THE BASE CLASS"<<endl;
    }
    };
    class derived2:public base{
    public:
    void print()
    {
    cout<<"IN THE BASE CLASS"<<endl;
    }
    };
    int main()
    {
    derived1 obj1;
    obj1.print();

    derived2 obj2;
    obj2.print();
    return 0;
    }

  20. name:Md Ashraful Hossain
    ID:137
    #include
    using namespace std;
    class base{
    public:
    void print()
    {
    cout<<"IN THE BASE CLASS"<<endl;}
    };
    class derived1:public base{
    public:
    void print()
    {
    cout<<"IN THE BASE CLASS"<<endl;
    }
    };
    class derived2:public base{
    public:
    void print()
    {
    cout<<"IN THE BASE CLASS"<<endl;
    }
    };
    int main()
    {
    derived1 obj1;
    obj1.print();
    derived2 obj2;
    obj2.print();
    return 0;
    }

  21. Name: Rois uddin Khan Emon
    Intake: 41
    Sec: 4
    ID: 18192103153

    #include
    #include

    using namespace std;

    class base{
    public:
    virtual void void_print(){
    cout<<"in the base class"<<endl;
    }
    };

    class derived1: public base{
    public:
    void void_print(){
    cout<<"in the derived1 class"<<endl;
    }
    };

    class derived2: public base{
    public:
    void void_print(){
    cout<<"in the derived2 class"<void_print();
    derived1 obj2;
    p=&obj2;
    p->void_print();
    derived2 obj3;
    p=&obj3;
    p->void_print();
    getch();
    return 0;
    }

  22. Name: Arman Hossain
    Id:18192103156

    #include
    using namespace std;
    class base{
    public:
    void void_print(){
    cout<< "In the base class"<<endl;
    }
    };
    class derived1: public base{
    public:
    void void_print(){
    cout<< "In the deriver1 class"<<endl;
    }
    };
    class derived2: public base{
    public:
    void void_print(){
    cout<< "In the deriver class"<<endl;
    }
    };
    int main()
    {
    base ob;
    ob.void_print();
    //derived1 ob2;
    //ob2.void_print();
    //derived2 ob3;
    //ob3.void_print();

    return 0;
    }

  23. //Name: Syeda Nafia Sultana, ID: 17181103058, Intake: 37A
    #include
    using namespace std;
    class base
    {
    public:
    void print()
    {cout<<"in the base class"<<endl;}
    };
    class derived1:public base
    {
    public:
    void print()
    {cout<<"in the base class"<<endl;}
    };
    class derived2:public base
    {
    public:
    void print()
    {cout<<"in the base class"<<endl;}
    };
    int main()
    {
    derived1 obj1;
    obj1.print();

    derived2 obj2;
    obj2.print();
    return 0;
    }

Leave an answer