Intro to Inheritance (intake 41 section 4)

Question

Create a class called Box(), that carries three data,length=l weight=w and hight=h. Create another class called area() that can calculate the volume of a box with its own function called volume(). Now inherit class to Box() to class area(). Then create an object of the class area and show the volume of Box.

in progress 0
Ask me anything 2 months 19 Answers 177 views 0

Answers ( 19 )

  1. Name: Arman Hossain

    Id:156

     

    #include <iostream>

    using namespace std;
    class Box
    {
    int i,w,h;
    public:
    Box(int x,int y,int z);
    };
    class Area: class Box
    {
    public:
    int volume();
    }
    void Area :: volume()
    {
    return(x*y*z);
    }
    int Box ::(int a, int b, int b);
    {
    i=x;
    w=y;
    h=z;
    }
    int main()
    {
    volume obj;
    obj.set_x(5);
    obj.set_y(6);
    obj.set_z(7);
    cout << “obj.Volume()” << endl;
    return 0;
    }

    Sir eita run nicche na. ki vul hoice  jodi ektu bolten.

  2. name:Md.Emon Ali

    Id:154

    #include<iostream>

    using namespace std;
    class box
    {
    public:
    int l,w,h ;
    int display1()
    {
    cout<<“Enter three values “<<endl;
    cin >> l ;
    cin >> w ;
    cin >> h ;
    }
    };

    class area : public box
    {

    public:
    void volume()
    {
    int A;

    A=l*w*h;
    }

    };

    int main()
    {
    int A;
    area ob;
    ob.display1();
    ob.volume();
    cout<<“The volume is “<<A;
    return 0;

    }

  3. Name: Tamanna Tasnim

    ID: 142

     

    #include <iostream>
    using namespace std;

    class box {
    public:
    int length, weight, hight;
    box()
    {
    cout << “Enter the length of the box: “<< endl;
    cin>>length;
    cout << “Enter the weight of the box: “<< endl;
    cin>>weight;
    cout << “Enter the hight of the box: “<< endl;
    cin>>hight;
    }

    };

    class area: public box{
    public:
    int volume()
    {
    int volume;
    volume=length*weight*hight;
    }
    };

    int main()
    {
    area obj;
    int volume;
    volume=obj.volume();
    cout << “Volume of the box is: “<< volume <<endl;

    return 0;
    }

  4. Name: TabassumMehrinProva

    ID:177

    #include<iostream>

    using namespace std;
    class box
    {
    public:
    int l,w,h ;
    int display1()
    {
    cout<<“Enter three values “<<endl;
    cin >> l ;
    cin >> w ;
    cin >> h ;
    }
    };

    class area : public box
    {

    public:
    void volume()
    {
    int A;

    A=l*w*h;
    }

    };

    int main()
    {
    int A;
    area ob;
    ob.display1();
    ob.volume();
    cout<<“The volume is “<<A;
    return 0;

    }

  5. Name:Nigar sultana era

    Id:175

    #include<iostream>

    using namespace std;
    class box
    {
    public:
    int l,w,h ;
    int display1()
    {
    cout<<“Enter three values “<<endl;
    cin >> l ;
    cin >> w ;
    cin >> h ;
    }
    };

    class area : public box
    {

    public:
    void volume()
    {
    int A;

    A=l*w*h;
    }

    };

    int main()
    {
    int A;
    area ob;
    ob.display1();
    ob.volume();
    cout<<“The volume is “<<A;
    return 0;

    }

  6. name: Moinul islam

    id : 180

    #include<iostream>
    using namespace std;
    class Box{

    int i, j, k;
    public:
    void set_box(int m, int n, int o);
    int show();
    int show2();
    int show3();
    };

    class area:public Box{

    public:
    int cal_area();
    };

    void Box::set_box(int m,int n,int o)
    {
    i=m;
    j=n;
    k=o;
    }
    //Box :: Show(int)
    int Box::show()
    {
    int m = i;
    }
    int Box::show2()
    {
    int n = j;
    }
    int Box::show3()
    {
    int o = k;
    }

    int area::cal_area()
    {
    return show()*show2()*show3();
    }
    int main()
    {
    area ob;
    ob.set_box(2,3,5);
    //ob.cal_area();
    cout<<ob.cal_area()<<endl;
    return 0;
    }

  7. Name: Rumman

    ID: 138
    Intake 41

     

    #include <iostream>
    using namespace std;

    class box {
    public:
    int length, weight, hight;
    box()
    {
    cout << “Enter the length of the box: “<< endl;
    cin>>length;
    cout << “Enter the weight of the box: “<< endl;
    cin>>weight;
    cout << “Enter the hight of the box: “<< endl;
    cin>>hight;
    }

    };

    class area: public box{
    public:
    int volume()
    {
    int volume;
    volume=length*weight*hight;
    }
    };

    int main()
    {
    area obj;
    int volume;
    volume=obj.volume();
    cout << “Volume of the box is: “<< volume <<endl;

    return 0;
    }

  8. ID:18192103149

    Intake:41; Section:04

    #include<iostream>

    using namespace std;
    class box
    {
    public:
    int l,w,h ;
    int display1()
    {
    cout<<“Enter three values “<<endl;
    cin >> l ;
    cin >> w ;
    cin >> h ;
    }
    };

    class area : public box
    {

    public:
    void volume()
    {
    int A;

    A=l*w*h;
    }

    };

    int main()
    {
    int A;
    area ob;
    ob.display1();
    ob.volume();
    cout<<“The volume is “<<A;
    return 0;

    }

  9. Name: Rakibul Hasan Shafin

    ID: 18192103165

    Intake: 41

     

    #include<iostream>

    using namespace std;
    class box
    {
    public:
    int l,w,h ;
    int display1()
    {
    cout<<“Enter three values “<<endl;
    cin >> l ;
    cin >> w ;
    cin >> h ;
    }
    };

    class area : public box
    {

    public:
    void volume()
    {
    int A;

    A=l*w*h;
    }

    };

    int main()
    {
    int A;
    area ob;
    ob.display1();
    ob.volume();
    cout<<“The volume is “<<A;
    return 0;

    }

  10. Name: Tahmid Hossain Rasel

    ID: 168

     

    #include <iostream>
    using namespace std;

    class box {
    public:
    int length, weight, hight;
    box()
    {
    cout << “Enter the length of the box: “<< endl;
    cin>>length;
    cout << “Enter the weight of the box: “<< endl;
    cin>>weight;
    cout << “Enter the hight of the box: “<< endl;
    cin>>hight;
    }

    };

    class area: public box{
    public:
    int volume()
    {
    int volume;
    volume=length*weight*hight;
    }
    };

    int main()
    {
    area obj;
    int volume;
    volume=obj.volume();
    cout << “Volume of the box is: “<< volume <<endl;

    return 0;
    }

  11. //Name: Syeda Nafia Sultana, ID: 17181103058, Intake: 37 //

    #include <iostream>
    using namespace std;
    class box
    {
    public:
    int l,w,h;
    box()
    {
    cout << “Enter the length, weight, hight of the box: “<< endl;
    cin>>l;cin>>w;cin>>h;
    }
    };
    class area : public box
    {
    public:
    int v()
    {
    int v;
    v=l*w*h;
    }
    };
    int main()
    {
    area obj;
    int v;
    v=obj.v();
    cout << “Volume of the box is: “<< v <<endl;
    return 0;
    }

  12. MD Ashraful Hossain

    ID-18192103137

     

    #include <iostream>
    using namespace std;

    class box {
    public:
    int length, weight, hight;
    box()
    {
    cout << “Enter the length of the box: “<< endl;
    cin>>length;
    cout << “Enter the weight of the box: “<< endl;
    cin>>weight;
    cout << “Enter the hight of the box: “<< endl;
    cin>>hight;
    }

    };

    class area: public box{
    public:
    int volume()
    {
    int volume;
    volume=length*weight*hight;
    }
    };

    int main()
    {
    area obj;
    int volume;
    volume=obj.volume();
    cout << “Volume of the box is: “<< volume <<endl;

    return 0;
    }

  13. Md.Muntasir Mamun

    Id.18192103179

     

    #include<iostream>

    using namespace std;
    class box
    {
    public:
    int l,w,h ;
    int display1()
    {
    cout<<“Enter three values “<<endl;
    cin >> l ;
    cin >> w ;
    cin >> h ;
    }
    };

    class area : public box
    {

    public:
    void volume()
    {
    int A;

    A=l*w*h;
    }

    };

    int main()
    {
    int A;
    area ob;
    ob.display1();
    ob.volume();
    cout<<“The volume is “<<A;
    return 0;

    }

  14. Name. Asfack uddin nabil

    Id.173

    Int. 41

    Sec. 4

    #include <iostream>
    using namespace std;
    class box
    {
    public:
    int l,w,h;
    box()
    {
    cout << “Enter the length, weight, hight of the box: “<< endl;
    cin>>l;cin>>w;cin>>h;
    }
    };
    class area : public box
    {
    public:
    int v()
    {
    int v;
    v=l*w*h;
    }
    };
    int main()
    {
    area obj;
    int v;
    v=obj.v();
    cout << “Volume of the box is: “<< v <<endl;
    return 0;
    }

  15. Arup Raton Chowdhury

    ID-18192103155

     

    #include <iostream>
    using namespace std;

    class box {
    public:
    int length, weight, hight;
    box()
    {
    cout << “Enter the length of the box: “<< endl;
    cin>>length;
    cout << “Enter the weight of the box: “<< endl;
    cin>>weight;
    cout << “Enter the hight of the box: “<< endl;
    cin>>hight;
    }

    };

    class area: public box{
    public:
    int volume()
    {
    int volume;
    volume=length*weight*hight;
    }
    };

    int main()
    {
    area obj;
    int volume;
    volume=obj.volume();
    cout << “Volume of the box is: “<< volume <<endl;

    return 0;
    }

  16. Name: Sanjara

    ID: 18192103166

    #include <iostream>
    using namespace std;

    class box {
    public:
    int length, weight, hight;
    box()
    {
    cout << “Enter the length of the box: “<< endl;
    cin>>length;
    cout << “Enter the weight of the box: “<< endl;
    cin>>weight;
    cout << “Enter the hight of the box: “<< endl;
    cin>>hight;
    }

    };

    class area: public box{
    public:
    int volume()
    {
    int volume;
    volume=length*weight*hight;
    }
    };

    int main()
    {
    area obj;
    int volume;
    volume=obj.volume();
    cout << “Volume of the box is: “<< volume <<endl;

    return 0;
    }

  17. Id-18192103150

    #include <iostream>
    using namespace std;

    class box {
    public:
    int length, weight, hight;
    box()
    {
    cout << “Enter the length of the box: “<< endl;
    cin>>length;
    cout << “Enter the weight of the box: “<< endl;
    cin>>weight;
    cout << “Enter the hight of the box: “<< endl;
    cin>>hight;
    }

    };

    class area: public box{
    public:
    int volume()
    {
    int volume;
    volume=length*weight*hight;
    }
    };

    int main()
    {
    area obj;
    int volume;
    volume=obj.volume();
    cout << “Volume of the box is: “<< volume <<endl;

    return 0;
    }

  18. NAME: Bushrat Jahan

    ID:18192103160

    SECTION: 04

    #include<bits/stdc++.h>
    using namespace std;
    class box{
    public:
    int length=5;
    int weight=6;
    int height=7;
    };
    class area: public box{
    public:
    void func()
    {
    cout<<“volume is: “<<length*weight*height<<endl;
    }
    };
    int main()
    {
    area obj;
    obj.func();
    return 0;
    }

  19. D.K.Shah Alam
    Id.18192103176

    #include
    using namespace std;
    class box
    { public:
    int l,w,h;
    };

    class area:public box
    {
    public:
    volume(int l,int w,int h)
    { int x;
    x=l*w*h;
    cout<<"Volume is "<<x;

    }
    };
    int main()
    {

    area obj;

    obj.volume(10,2,1);
    return 0;
    }

Leave an answer