C++ data structure assignment

Programming

1. For this problem, you will be asked to write some code to accomplish a particular task given the code fragment below. Each task will depend on the tasks that came before it. Your code must be syntactically correct.

int i1 = 100;_x000D_
int i2 = -8;_x000D_
int i3 = 15;   _x000D_
_x000D_
int *p1, **p2, ***p3;_x000D_

a.) Set p1 to point to i1.

b.) Using p2 change the value of i1 to the value of i2 (you may not use i1).

c.) Using p3 make p1 point to i3 (you may not use p1).

2. Consider the code fragment below. It is supposed to construct a 3×4 (3 rows 4 columns) 2-level array of integers and set each value to zero. However, as given it does not. Add the proper dereferences (*) or references (&) to make this code work properly:

int rows,  col1,  col2,  col3;_x000D_
rows = new int [3]; // Create 3 pointers to columns _x000D_
col1 = new int [4]; // Create first row with 4 elements _x000D_
col2 = new int [4]; // Create second row with 4 elements _x000D_
col3 = new int [4]; // Create third row with 4 elements_x000D_
( rows+0)= col1[0]; //Pointtofirstrow _x000D_
( rows+1)= col2[0]; //Pointtosecondrow _x000D_
( rows+2)= col3[0]; //Pointtothirdrow_x000D_
( rows+0)= col1[0]; //Pointtofirstrow _x000D_
( rows+1)= col2[0]; //Pointtosecondrow _x000D_
( rows+2)= col3[0]; //Pointtothirdrow_x000D_
 for (int i = 0; i<3; i++)_x000D_
    for (int j = 0; j<4; j++)_x000D_
           ( ( rows+i)+j) = 0;   //rows[i][j]=0; 

3. For this problem, you will be asked to write some code to accomplish a particular task given the code fragment below. Each task may depend on the tasks that came before it. Your code must be syntactically correct. Note none of your operations may affect S::m_unique.

class S {_x000D_
      public:_x000D_
           S(int init, int id) :m_num(init)_x000D_
               { m_unique = new int(id);} _x000D_
           S() :m_num(0) _x000D_
               { m_unique = new int(-1);}_x000D_
           ~S()_x000D_
               { delete m_unique; }_x000D_
           ..._x000D_
           void set(int num) _x000D_
               { m_num = num;}_x000D_
           int get() _x000D_
               { return m_num; }_x000D_
      private:_x000D_
           int m_num;_x000D_
           int *m_unique;_x000D_
                              };_x000D_
_x000D_
      S d1, d2(4,2), d3(-15,3);_x000D_
      S *sp1, **sp2, ***sp3;

a) Set sp1 to point to d1.

b) Using sp2 change the value of m_num in d1 to the value of m_num in d2 (you may not use d1).

c) Using sp3 make sp1 point to d3 (you may not use sp1).

4. Referring to the object S in previous problem:

a) Implement a copy constructor for the object S. Assume this is done inside the class definition.

b) Overload the assignment operator for the object S. Assume this is done inside the class definition.

#write essay #research paper #blog writing #article writing #academic writer #reflective paper #essay pro #types of essays #write my essay #reflective essay #paper writer #essay writing service #essay writer free #essay helper #write my paper #assignment writer #write my essay for me #write an essay for me #uk essay #thesis writer #dissertation writing services #writing a research paper #academic essay #dissertation help #easy essay #do my essay #paper writing service #buy essay #essay writing help #essay service #dissertation writing #online essay writer #write my paper for me #types of essay writing #essay writing website #write my essay for free #reflective report #type my essay #thesis writing services #write paper for me #research paper writing service #essay paper #professional essay writers #write my essay online #essay help online #write my research paper #dissertation writing help #websites that write papers for you for free #write my essay for me cheap #pay someone to write my paper #pay someone to write my research paper #Essaywriting #Academicwriting #Assignmenthelp #Nursingassignment #Nursinghomework #Psychologyassignment #Physicsassignment #Philosophyassignment #Religionassignment #History #Writing #writingtips #Students #universityassignment #onlinewriting #savvyessaywriters #onlineprowriters #assignmentcollection #excelsiorwriters #writinghub #study #exclusivewritings #myassignmentgeek #expertwriters #art #transcription #grammer #college #highschool #StudentsHelpingStudents #studentshirt #StudentShoe #StudentShoes #studentshoponline #studentshopping #studentshouse #StudentShoutout #studentshowcase2017 #StudentsHub #studentsieuczy #StudentsIn #studentsinberlin #studentsinbusiness #StudentsInDubai #studentsininternational