I have two questions I am stuck on, would appreciate explanation along with answ
ID: 3555350 • Letter: I
Question
I have two questions I am stuck on, would appreciate explanation along with answers.
Given the declaration:
class myClass
{
public:
void print();
private:
int x;
};
myClass myObject;
which statement is legal?
myObject.print = 10;
myClass.print = 10;
myObject.print();
myClass.print();
*******************************
Given the following code and for the following for loop, what is the statement that will initialize the elements of the array to a value of 0 using pointer arithmetic?
Int array[10];
int * arrayPointer = array;
int k = 0;
for(k = 0; k < 10; k++)?
*(arrayPointer +i) = 0;
arrayPointer*k = 0;
*(arrayPointer + k) = 0;
*(arrayPointer) + k = 0;
Explanation / Answer
1 myObject.print = 10;
2 *(arrayPointer + k) = 0