Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

9.1 and 9.2 C++ dot (.), arrow ( rightarrow ). b) private. c) public. d) Default

ID: 3820832 • Letter: 9

Question


9.1 and 9.2 C++ dot (.), arrow ( rightarrow ). b) private. c) public. d) Default memberwise assignment (performed by the assignment operator). e) friend. f) initialized. g) static. h) this. i) const. j) default constructor. k) non-static. I) before. a) Error: Destructors are not allowed to return values (or even specify a return type) or take arguments. Correction: Remove the return type void and the parameter int from the declaration. b) Error: Constructors are not allowed to return values. Correction: Remove the return type int from the declaration. c) Error: The class definition for Example has two errors. The first occurs in function get-IncrementedData. The function is declared const, but it modifies the object. Correction: To correct the first error, remove the const keyword from the definition of getIncrementedData. Error: The second error occurs in function getCount. This function is declared static, so it's not allowed to access any non-static class member (i.e., data). Correction: To correct the second error, remove the output line from the getCount definition.

Explanation / Answer

9.1 Answers Explanation :

a)dot(.): dot operator cannot be overloaded
arrow(->): arrow operator can be overloaded
b)private: These members are only accessible within the class. outside classes cannot access it
c)public: members declared as public are accessible from outside the class through an object of that class.
d)assignment operator: Assignment operator can be overloaded.It is a special case of assignment operator where the right-hand side and left-hand side are of the same class type.
e)friend: Friend function have access to all private and protected members of that class
f)initiazed: initialization is performed when a variable is constructed with an empty initializer.
g)static: By declaring a function member as static you can make it independant of any particular object of that class
h)this: this pointer holds the memory address of the current object
i)const: using const keyword you cannot change its value
j)default constructor: default constructor doesn't have any parameters and all the parameters have default values
k)non-static: non static member function can be declared as volatile ,const etc.

9.2 Answers Explanation :

a)Destructors doesn't contain return type because it is not called directly in your code,but it is called by memory allocation during run time.Its value is not visile to the user.
b)Constructors doesn't return any values the reason is same as destructors.
c)Based on code snipphet we need to make the changes.