NPTEL Programming in C++ Week4 Assignment-4 Solutions 2021 | Swayam


Gaming Mouse with 3.9 to 4.00 rating


       
               

Zinq Technologies 1070 3200 DPI LED Backlight 6 Button USB Gaming Mouse with Nylon Braided Cable (Black)


Rating - 3.9 to 4

Price - 400₹ to 500₹

for latest information click - https://amzn.to/2Ow6dXD




 Ans of Programming_Qs1

#include<iostream>

using namespace std;

class Test1{

    int x;

public:

    Test1(int _x):X(_X){COUT<<"class 1: ";}

    friend void print(int,int)    //Line-1

};

class Test2{

    int y;

public:

    Test2(int _y):y(_y){cout<<"class 2: ";}

    friend void print(int,int)   //Line-2

};


Ans of Programming_Qs2

#include<iostream>

using namespace std;

class positionVector{

    int x,y;

public:

    positionVector(int a,int b):x(a),y(b){}

    positionVector operator+(positionVector pv){   //Line-1

        positionVector p(0,0);

        p.x = this->x+pv.x;                        //Line-2

        p.y = this->y+pv.y;                        //Line-3

        return p;

    }

};


Ans of Programming_Qs3

#include<iostream>

using namespace std;

class Student{

    const int id;

    string name;


    mutable int marks;                                     //Line-1

public:

    Student(int a,int b,int c):id(a),name(b),marks(c){}

    void updateMarks(int x) const{{marks+=x;}             //Line-2

    void print() const{                                   //Line-3



Ans of Programming_Qs4

#include<iostream>

using namespace std;

class database{

    int data;


    static database *dbObject;                 //Line-1

    database(int x):data(x){}

public:

    static database* connect(int x){          //Line-2

        if(!dbObject)

            dbObject=new database(x)          //Line-3

        return dbObject;

    }

};



No comments:

Powered by Blogger.