I am a newbie into C++ programming, I and am currently reading this book called Jumping to C++Jumping to C++ by Alex Allain, currently. I have finished the Pointers Chapterpointers chapter and I am doing the Exercisesexercises at the end of the Chapterchapter.
- 1. Write a function that prompts the user to enter his or her first name and last name, as two separate
values. This function should return both values to the caller via additional pointer (or reference)
parameters that are passed to the function. Try doing this first with pointers and then with references.
(Hint: the function signature will look be similar to the swap function from earlier!)
MY SOURCE CODE FOR THAT EXERCISE IS:
Write a function that prompts the user to enter his or her first name and last name, as two separate values. This function should return both values to the caller via additional pointer (or reference) parameters that are passed to the function. Try doing this first with pointers and then with references. (Hint: the function signature will look be similar to the swap function from earlier!)
- 2. The next exercise is to Modify the program I wrote for exercise 1 so that instead of always prompting the user for a last
name, it does so only if the caller passes in a NULL pointer for the last name.
MY SOURCE CODE FOR THAT NEXT EXERCISE IS:
The next exercise is to modify the program I wrote for exercise 1 so that instead of always prompting the user for a last name, it does so only if the caller passes in a NULL pointer for the last name.
If possible, I'd like to know if I did right for both of the exercise and Ifif I am in the right direction, Comments. Comments and Tipstips will be helpful.