Question: 1. Which statement about the C++ pointers in general is incorrect? 2. Which statement about the usage of pointers is incorrect? Question 1 Which statement
Question 1 Which statement about the C++ pointers in general is incorrect? Pointer is just like a nominal variable, can be declared with an additional *** placed between the data type and the identifier. The address of operator "&" can exact the assigned memory addess of a variable or data type. The size of pointer can be checked by the sizeof() function and it should be always 8 bytes regardless of the data types. Adding the dereference operator *** in front of a pointer would extract the value that stored at the given memory address. Using "int *p" and "int* p" are both allowed, but the former case is more preferred. Question 2 Which statement about the usage of pointers is incorrect? Using the pointer in an improper way is very likely to crash your program. Pointer can only hold the addresses, and if you try to print out the pointer, it is usually represented in hex Adopting pointer in code could be unsafe since there is no real protection, so you should avoid to use it. By convension if a pointer is pointing to nothing, we can assign zero or nullptr to it. Pointer is extremely powerful since it allows a direct access to the computer memory
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
