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 1 month 1 Answer 41 views 0

Answer ( 1 )

  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;
    }

Leave an answer