Constructor That Takes Parameters (Intake 41 section 4)

Question

A class declares a constructor that takes two parameters. Write a simple example of it.

in progress 0
Ask me anything 8 months 16 Answers 181 views 0

Answers ( 16 )

  1. D.K.Shah Alam
    id.18192103176

    #include
    using namespace std;
    class Example
    {
    public:
    int a,b;
    Example(int x,int y)
    {
    x=a;y=b;
    }
    };
    int main()
    {
    Example Ex();
    return 0;
    }

  2. Name: Tamanna Tasnim
    ID: 142

    #include
    using namespace std;
    class myclass
    {
    public:
    int a,b;
    myclass(int x,int y)
    {
    x=a;y=b;
    }
    };
    int main()
    myclass ob();
    return 0;
    }

  3. NAME:Md. Emon Ali
    ID:154
    #include
    using namespace std;
    class myclass
    {
    public:
    int a,b;
    myclass(int x,int y)
    {
    x=a;y=b;
    }
    };
    int main()
    myclass ob();
    return 0;
    }

  4. //Name: Syeda Nafia Sultana, ID: 17181103058, Intake: 37//
    #include
    using namespace std;

    class myclass {
    private:
    int x, y;

    public:
    myclass(int x1, int y1){x=x1; y=y1;}
    int getX(){return x;}
    int getY(){return y;}
    };
    int main()
    {
    myclass c1(10, 15);
    cout << "x = " << c1.getX() << ", y = " << c1.getY();
    return 0;
    }

  5. Name: MD Masudul Islam Asif
    ID : 147

    #include
    using namespace std;
    class myclass
    {
    public:
    int a,b;
    myclass(int x,int y)
    {
    x=a;y=b;
    }
    };
    int main()
    myclass ob();
    return 0;
    }

  6. Asfack uddin nabil
    Id.. 173

    #include
    using namespace std;
    class myclass
    {
    public:
    int a,b;
    myclass(int x,int y)
    {
    x=a;y=b;
    }
    };
    int main()
    myclass ob();
    return 0;
    }

  7. ID:18192103149
    #include
    using namespace std;
    class myclass
    {
    public:
    int a,b;
    myclass(int x,int y)
    {
    x=a;y=b;
    }
    };
    int main()
    myclass ob();
    return 0;
    }

  8. Name: sabila Rahman
    ID:136

    #include
    using namespace std;
    class input
    {
    public:
    int length,width;
    input(int i,int j)
    {
    length=i;
    width=j;
    }
    virtual void area()
    {
    cout<<" "<<'n';
    }
    virtual void perimeter()
    {
    cout<<" "<<'n';
    }
    };
    class square:public input
    {
    public:
    square(int i):input(i)
    {}
    void area()
    {
    cout<< length*length<< 'n';
    }
    };
    class triangle:public input
    {
    public:
    triangle(int i,int j):input(i,j)
    {}
    void perimeter()
    {
    cout<<0.5*length*widthperimeter();
    return 0;
    }

  9. Name: Rakibul Hasan Shafin
    ID: 18192103165
    Intake: 41
    Seection: 04
    #include
    using namespace std;
    class Example
    {
    public:
    int a,b;
    Example(int x,int y)
    {
    x=a;y=b;
    }
    };
    int main()
    {
    Example Ex();
    return 0;
    }

  10. #include
    #include
    using namespace std;

    class myclass{
    public:
    int a, b;
    myclass(int a, int b){
    cout<< a << 'n'<< b <<endl;
    }
    };
    int main(){
    myclass obj(10, 30);
    return 0;

    }

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

    #include
    #include
    using namespace std;

    class myclass{
    public:
    int a, b;
    myclass(int a, int b){
    cout<< a << 'n'<< b <<endl;
    }
    };
    int main(){
    myclass obj(10, 30);
    return 0;

    }

  12. Name: MD Tayeb
    Id: 18192103164

    #include
    using namespace std;
    class myclass
    {
    public:
    int a,b;
    myclass(int x,int y)
    {
    x=a;y=b;
    }
    };
    int main()
    myclass ob();
    return 0;
    }

  13. #include
    using namespace std;
    class Example
    {
    public:
    int a,b;
    Example(int x,int y)
    {
    x=a;y=b;
    }
    };
    int main()
    {
    Example Ex();
    return 0;
    }

  14. Md Ashraful Hossain
    id.18192103137
    #include
    using namespace std;
    class Example
    {
    public:
    int a,b;
    Example(int x,int y)
    {
    x=a;y=b;
    }
    };
    int main()
    {
    Example Ex();
    return 0;
    }

  15. Mahbubur Rahman khan
    id-18192103150

    #include
    using namespace std;
    class Example
    {
    public:
    int a,b;
    Example(int x,int y)
    {
    x=a;y=b;
    }
    };
    int main()
    {
    Example Ex();
    return 0;
    }

  16. shaminur rahman
    id:18192103158
    #include
    using namespace std;
    class Example
    {
    public:
    int a,b;
    Example(int x,int y)
    {
    x=a;y=b;
    }
    };
    int main()
    {
    Example Ex();
    return 0;
    }

Leave an answer