NPTEL Programming in C++ Week3 Assignment-3 Solutions 2021 | Swayam


Ans of  Programming_Q1

class Point{

const x,y;

public:

    Point(int _x=0,int _y=0): x(_x),y(_y) {}

    Point(const Point& p):x(x.p),y(y.p){}

    double distance(Point p){

        return sqrt(pow(p.x-x,2)+pow(p.y-y,2)*1.0);

    }

};

Ans of  Programming_Q2

class IntArray{

    int *arr;

    int size;

public:

    IntArray(int n):arr(new int[n]),size(n){}

    ~IntArray(){delete[] arr;}

}

Ans of  Programming_Q3

Myclass(char *s):str(s){}

    ~Myclass(){delete str;}

    Myclass& operator=(Myclass& m){    

 


 

No comments:

Powered by Blogger.