Question: Using C++ language. Define a class with name ArrayAccess, this class has only one attribute, it is an int type array with 100 elements. Define
Using C++ language.
- Define a class with name ArrayAccess, this class has only one attribute, it is an int type array with 100 elements.
Define a constructor and four methods for ArrayAccess.
Define a constructor.
The constructor initializes the values of the array randomly. But the values are not bigger than 10000, not less than 0.
Define four methods.
The first method prints all values line by line by using traditional way to access each element. ArrayName[index]
The second method prints all values line by line by using pointer. *(arrayvariable+index)
The third method print the addresses of all elements line by line by using address-of operator &.
The fourth method filter out 0,100,1000,10000 and print their English names ZERO, One Hundred, One Thousand, Ten Thousand. Use C++ switch statement and for statement.
Test your work in main method by creating an object and calling each method.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
