Answered step by step
Verified Expert Solution
Question
1 Approved Answer
1. Which statement about pointers and arrays is incorrect? 2. Which statement about C++ reference is incorrect? Question 3 Which statement about pointers and arrays
1. Which statement about pointers and arrays is incorrect?
Question 3 Which statement about pointers and arrays is incorrect? C-style string is also an array of char type. The only key point is to end the string with an ASCII code 0. When using a C-style array as function argument, it decays to a pointer. The information about the array size is lost. A char array like "char name[8]" can only store a string of 7 characters. The C-style array can be also considered to be a pointer which is pointing to the address of the first element of the array. We can jump to next element in an array by adding interger to the pointer. If you want to jump to next number in a double array (e.g. "double array(10)"), you should +8 to the pointer since the size of double is 8 bytes. Question 4 Which statement about C++ reference is incorrect? For accessing the members of a struct pointer, we have to use ">" operator, but for a struct reference, we are using the regular":" member selection operator References must be initialized when created and cannot be re-assigned to a different object. When passing a reference as function parameter, any modification on the reference will be kept and effect on the original object. Creating a reference in C++ is very similar to make an alias to another object. Just like the pointer, the returned value of applying sizeof() to a reference is also decided by the system architecture 2. Which statement about C++ reference is incorrect?
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started