当前位置:天才代写 > 作业代写 > COEN 79代写 面向对象编程代写 高级数据结构代写

COEN 79代写 面向对象编程代写 高级数据结构代写

2021-07-26 17:11 星期一 所属: 作业代写 浏览:48

COEN 79


Object-Oriented Programming and Advanced Data Structures


Assignment #1


COEN 79代写 1.(4 pts)Design a class for a point in polar-coordinates (r, theta), r, radius, is in cm and theta is in degrees with the following ···

1.(4 pts)

Design a class for a point in polar-coordinates (r, theta), r, radius, is in cm and theta is in degrees with the following member functions:

default constructor (0, 0)

getters: get_r and get_angle

setter: set_angle

please provide an example of a main function using

the polar coordinates.

 

2.(2 pts)  COEN 79代写

What is the time complexity of fun(). Please show your proof.

int fun(int n)
{
int count = 0;
for (int i = n; i > 0; i /= 2)
for (int j = 0; j < i; j++)
count += 1;
return count;
}

3.(1 pt)

Give a concise formula that gives the approximate number of digits in a positive integer. The integer is written in base 10.

 

4.(2 pts)  COEN 79代写

What are the differences between references and pointers?

 

5.(3 pts)

What are the three ways we can use items defined in a namespace. Include examples in your answer.

 

6.(2 pts)   COEN 79代写

Discuss about the output of the following code. How the result will change if we replace struct with class?

1.   struct Test {
2.          int x;
3.   };
4.
5.   int main() {
6.           Test t;
7.           t.x = 20;
8.           cout<t.x<endl;
9.           return 0;
10.  }

 

 

7.(2 pts)  COEN 79代写

A The header of the point class is as follows:

1.   class point
2.   {
3.   public:
4.                 // CONSTRUCTOR
5.                 point (double initial_x = 0.0, double initial_y = 0.0);
6.
7.                 // MODIFICATION MEMBER FUNCTIONS
8.                 void set_x (double& value);
9.                 void set_y (double& value);
10.
11.                 // CONST MEMBER FUNCTIONS
12.                 point operator+ (double& in) const;
13.
14.  private:
15.            double x; // x coordinate of this point
16.            double y; // y coordinate of this point
17.
18.    };

 

COEN 79代写
COEN 79代写

 

  • Which line of the following code results in an error? Explain why.
  • What’s the solution?

1.   main() {
2.        point myPoint1, myPoint2, myPoint3;
3.        double shift = 8.5;
4.        myPoint1 = shift + myPoint2;
5.        myPoint3 = myPoint1.operator+ (shift);
6.        myPoint1 = myPoint1 + shift;
7.   }

 

8.(2 pts)  COEN 79代写

What is the output of this code? Discuss your answer.

1.   #include < iostream >
2.   using namespace std;
3.
4.   class CMyClass {
5.        public:
6.             static int m_i;
7.   };
8.
9.    int CMyClass::m_i = 0;
10.
11.   CMyClass myObject1;
12.   CMyClass myObject2;
13.   CMyClass myObject3;
14.
15.   int main() {
16.          CMyClass::m_i = 2;
17.          myObject1.m_i = 1;
18.
19.         cout << myObject1.m_i << endl;
20.         cout << myObject2.m_i << endl;
21.
22.         myObject2.m_i = 3;
23.         myObject3.m_i = 4;
24.
25.         cout << myObject1.m_i << endl;
26.         cout << myObject2.m_i << endl;
27.   }

 

 

COEN 79代写
COEN 79代写

 

其他代写:code代写 assembly代写 CS代写 Data Analysis代写 data代写 澳大利亚代写 essay代写 assignment代写 analysis代写 homework代写 Exercise代写 加拿大代写 英国代写 作业代写 app代写 algorithm代写 作业加急 北美代写  北美作业代写

合作平台:essay代写 论文代写 写手招聘 英国留学生代写

 

 

 

天才代写-代写联系方式