Object Oriented Programming Practice (Intake 41)

Question

Write a program that creates a base class called Base.This class has two integer values named x and y which also contain one virtual function called fun(). There is also a constructor which will take a parameter to assign value to x only. Now create a derived class named Derived.It has a constructor to assign value to y.Now override the fun() function to show the value of x and y.

in progress 0
Ask me anything 7 months 28 Answers 297 views 2

Answers ( 28 )

  1. ID- 18192103180

    #include
    using namespace std;
    class base{
    public:
    int i,j;
    base(int x,int y) {i=x;j=y;}
    virtual void fun()
    {
    cout<<" ";

    }
    };
    class derived : public base{
    public:
    derived(int x,int y):base(x,y) {}
    void fun()
    {
    cout<<i<<endl<fun();
    p=&ob1;
    p->fun();
    return 0;
    }

    • Name.. Asfack uddin nabil
      Id…173
      Sec…4

      #include
      using namespace std;
      class base{
      public:
      int i,j;
      base(int x,int y) {i=x;j=y;}
      virtual void fun()
      {
      cout<<" ";

      }
      };
      class derived : public base{
      public:
      derived(int x,int y):base(x,y) {}
      void fun()
      {
      cout<<i<<endlfun();
      return 0;
      }

  2. Name:Shamima Akter Shimu id:18192103144 #include
    using namespace std;
    class base{
    public:
    int i,j;
    base(int x,int y) {i=x;j=y;}
    virtual void fun()
    {
    cout<<" ";

    }
    };
    class derived : public base{
    public:
    derived(int x,int y):base(x,y) {}
    void fun()
    {
    cout<<i<<endlfun();
    return 0;
    }

  3. Name: Mosraful Habib
    ID: 172

    #include
    using namespace std;
    class base{
    public:
    int i,j;
    base(int x,int y) {i=x;j=y;}
    virtual void fun()
    {
    cout<<" ";

    }
    };
    class derived : public base{
    public:
    derived(int x,int y):base(x,y) {}
    void fun()
    {
    cout<<i<<endlfun();
    return 0;
    }

  4. Name: Tamanna Tasnim
    ID:142

    #include
    using namespace std;
    class base
    {
    public:
    int i,j;
    base(int x,int y)
    {i=x
    ;j=y;}
    virtual void fun()
    {
    cout<<" "<<'n';

    }
    };
    class derived : public base
    {
    public:
    derived(int x,int y):base(x,y)
    {}
    void fun()
    {
    cout<<i*jfun();
    return 0;
    }

  5. ID:18192103149
    #include
    using namespace std;
    class base
    {
    public:
    int i,j;
    base(int x,int y)
    {i=x
    ;j=y;}
    virtual void fun()
    {
    cout<<" "<<'n';

    }
    };
    class derived : public base
    {
    public:
    derived(int x,int y):base(x,y)
    {}
    void fun()
    {
    cout<<i*jfun();
    return 0;
    }

  6. Name:Md. Emon Ali
    Id:154
    #include
    using namespace std;
    class base{
    public:
    int i,j;
    base(int x,int y) {i=x;j=y;}
    virtual void fun()
    {
    cout<<" ";

    }
    };
    class derived : public base{
    public:
    derived(int x,int y):base(x,y) {}
    void fun()
    {
    cout<<i<<endl<fun();
    p=&ob1;
    p->fun();
    return 0;
    }

  7. Name:Tabassum Mehrin Prova
    ID:177
    #include
    using namespace std;
    class base{
    public:
    int i,j;
    base(int x,int y) {i=x;j=y;}
    virtual void fun()
    {
    cout<<" ";

    }
    };
    class derived : public base{
    public:
    derived(int x,int y):base(x,y) {}
    void fun()
    {
    cout<<i<<endl<fun();
    p=&ob1;
    p->fun();
    return 0;
    }

  8. Name: Rakibul Hasan Shafin
    ID: 18192103165
    Intake: 41
    Section: 04
    #include
    using namespace std;
    class base{
    public:
    int i,j;
    base(int x,int y) {i=x;j=y;}
    virtual void fun()
    {
    cout<<" ";

    }
    };
    class derived : public base{
    public:
    derived(int x,int y):base(x,y) {}
    void fun()
    {
    cout<<i<<endlfun();
    return 0;
    }

  9. Name: Nigar sultana Era
    Id:175
    #include
    using namespace std;
    class base{
    public:
    int i,j;
    base(int x,int y) {i=x;j=y;}
    virtual void fun()
    {
    cout<<" ";

    }
    };
    class derived : public base{
    public:
    derived(int x,int y):base(x,y) {}
    void fun()
    {
    cout<<i<<endl<fun();
    p=&ob1;
    p->fun();
    return 0;
    }

  10. Name: Md. Mintu Hossain
    ID: 17181103110
    Intake: 37

    #include
    using namespace std;
    class base{
    public:
    int x,y;
    base(int i,int j) {
    x=i; y=j;}
    virtual void fun()
    {
    cout<<"X = "<<x<<endl;
    }
    };
    class derived : public base{
    public:
    derived(int x, int y):base(x,y) {}
    void fun()
    {
    cout<<"Y = "<<y<fun();
    p=&ob1;
    p->fun();
    return 0;
    }

  11. //Name: Syeda Nafia Sultana,Intake: 37,ID: 171811103058
    #include
    using namespace std;
    class base{
    public:
    int i,j;
    base(int x,int y) {i=x;j=y;}
    virtual void fun()
    {cout<<" ";}};
    class derived:public base{
    public:
    derived(int x,int y):base(x,y) {}
    base::base()
    {cout<<y=;}
    void fun()
    int main ()
    {
    cout<<i<<j<<endlfun();
    return 0;
    }

  12. Name: Hasebul Hassan Siam
    ID: 18192103162
    Intake: 41
    Section: 04
    #include
    using namespace std;
    class base{
    public:
    int i,j;
    base(int x,int y) {i=x;j=y;}
    virtual void fun()
    {
    cout<<" ";

    }
    };
    class derived : public base{
    public:
    derived(int x,int y):base(x,y) {}
    void fun()
    {
    cout<<i<<endlfun();
    return 0;
    }

  13. ID:18192103139

    #include
    using namespace std;
    class base{
    public:
    int i,j;
    base(int x,int y) {i=x;j=y;}
    virtual void fun()
    {
    cout<<" ";

    }
    };
    class derived : public base{
    public:
    derived(int x,int y):base(x,y) {}
    void fun()
    {
    cout<<i<<endlfun();
    return 0;
    }

  14. Md. Jahinur islam
    Id: 169

    #include
    using namespace std;
    class base{
    public:
    int i,j;
    base(int x,int y) {i=x;j=y;}
    virtual void fun()
    {
    cout<<" ";

    }
    };
    class derived : public base{
    public:
    derived(int x,int y):base(x,y) {}
    void fun()
    {
    cout<<i<<endlfun();
    return 0;
    }

  15. Sabila
    Id: 136

    #include
    using namespace std;
    class base{
    public:
    int i,j;
    base(int x,int y) {i=x;j=y;}
    virtual void fun()
    {
    cout<<" ";

    }
    };
    class derived : public base{
    public:
    derived(int x,int y):base(x,y) {}
    void fun()
    {
    cout<<i<<endlfun();
    return 0;
    }

  16. Name: Rois Uddin Khan Emon
    ID: 18192103153
    Intake: 41
    Sec: 4

    #include
    using namespace std;
    class base{
    public:
    int i,j;
    base(int x,int y) {i=x;j=y;}
    virtual void fun()
    {
    cout<<" ";

    }
    };
    class derived : public base{
    public:
    derived(int x,int y):base(x,y) {}
    void fun()
    {
    cout<<i<<endlfun();
    return 0;
    }

  17. Name: nasrin
    Id: 157

    #include
    using namespace std;
    class base{
    public:
    int i,j;
    base(int x,int y) {i=x;j=y;}
    virtual void fun()
    {
    cout<<" ";

    }
    };
    class derived : public base{
    public:
    derived(int x,int y):base(x,y) {}
    void fun()
    {
    cout<<i<<endlfun();
    return 0;
    }

  18. Name: MD Masudul Islam Asif
    ID : 147

    #include
    using namespace std;
    class base{
    public:
    int i,j;
    base(int x,int y) {i=x;j=y;}
    virtual void fun()
    {
    cout<<" ";

    }
    };
    class derived : public base{
    public:
    derived(int x,int y):base(x,y) {}
    void fun()
    {
    cout<<i<<endlfun();
    return 0;
    }

  19. Name: MD Tayeb
    Intake: 41
    Sec: 4
    ID:18192103164

    #include
    using namespace std;
    class base
    {
    public:
    int i,j;
    base(int x,int y)
    {i=x
    ;j=y;}
    virtual void fun()
    {
    cout<<" "<<'n';

    }
    };
    class derived : public base
    {
    public:
    derived(int x,int y):base(x,y)
    {}
    void fun()
    {
    cout<<i*jfun();
    return 0;
    }

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

    #include
    using namespace std;
    class base{
    public:
    int x,y;
    base(int a) {x=a;}
    virtual void fun()
    {
    cout<<" ";

    }
    };
    class derived : public base{
    public:
    derived(int b):base(y) {}
    void fun()
    {
    cout<<x<<endl<<y;
    }
    };
    int main()
    {
    base ob(5);
    derived ob2(10);
    ob2.fun();
    return 0;

    }

  21. Name.. Arup Raton Chowdhury
    Id…155
    Sec…4

    #include
    using namespace std;
    class base{
    public:
    int i,j;
    base(int x,int y) {i=x;j=y;}
    virtual void fun()
    {
    cout<<" ";

    }
    };
    class derived : public base{
    public:
    derived(int x,int y):base(x,y) {}
    void fun()
    {
    cout<<i<<endlfun();
    return 0;
    }

  22. Name: MD Ashrafl Hossain
    ID: 137
    #include
    using namespace std;
    class base{
    public:
    int i,j;
    base(int x,int y) {i=x;j=y;}
    virtual void fun()
    {
    cout<<" ";
    }
    };
    class derived : public base{
    public:
    derived(int x,int y):base(x,y) {}
    void fun()
    {
    cout<<i<<endlfun();
    return 0;
    }

  23. Name : Rois Uddin Khan Emon
    Intake: 41
    Section: 4
    ID: 18192103153

    #include
    #include

    using namespace std;

    class Base{
    public:
    int x,y;
    Base(int i,int j){
    x=i;
    y=j;
    }
    virtual void fun(){
    cout<<x<<endl<<y<<endl;
    }
    };
    class Derived : public Base{
    public:
    Derived(int i,int j): Base(i,j){}
    void fun(){
    cout <<x<<endl<fun();
    getch();
    return 0;
    }

  24. #include
    using namespace std;
    class base{
    public:
    int x,y;
    base(int a) {x=a;}
    virtual void fun()
    {
    cout<<" ";

    }
    };
    class derived : public base{
    public:
    derived(int b):base(y) {}
    void fun()
    {
    cout<<x<<endl<<y;
    }
    };
    int main()
    {
    base ob(5);
    derived ob2(10);
    ob2.fun();
    return 0;

    }

    • Name:Arman Hossain
      Id:18192103156

      #include
      using namespace std;
      class base{
      public:
      int x,y;
      base(int a) {x=a;}
      virtual void fun()
      {
      cout<<" ";

      }
      };
      class derived : public base{
      public:
      derived(int b):base(y) {}
      void fun()
      {
      cout<<x<<endl<<y;
      }
      };
      int main()
      {
      base ob(5);
      derived ob2(10);
      ob2.fun();
      return 0;

      }

  25. mahbubur rahman khan
    id-18192103150

    #include
    using namespace std;
    class base
    {
    public:
    int i,j;
    base(int x,int y)
    {i=x
    ;j=y;}
    virtual void fun()
    {
    cout<<" "<<'n';

    }
    };
    class derived : public base
    {
    public:
    derived(int x,int y):base(x,y)
    {}
    void fun()
    {
    cout<<i*jfun();
    return 0;
    }

  26. Sorry it a private answer.

Leave an answer