Skip to main content
edited tags
Link
200_success
  • 145.7k
  • 22
  • 191
  • 481
deleted 118 characters in body; edited tags; edited title
Source Link
Jamal
  • 35.2k
  • 13
  • 134
  • 238

Am I using C++ Pointerspointers and Referencesreferences correctly?

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.

Am I using C++ Pointers and References correctly?

I am a newbie in C++ programming, I am currently reading this book called Jumping to C++ by Alex Allain, currently finished the Pointers Chapter and I am doing the Exercises at the end of the Chapter.

    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:

    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:

If possible I'd like to know if I did right for both of the exercise and If I am in the right direction, Comments and Tips will be helpful.

Am I using C++ pointers and references correctly?

I am a newbie to C++ programming and am currently reading this book called Jumping to C++ by Alex Allain. I have finished the pointers chapter and I am doing the exercises at the end of the chapter.

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!)

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 if I am in the right direction. Comments and tips will be helpful.

Tweeted twitter.com/#!/StackCodeReview/status/287737137313509376
Updated title and removed obsolete homework tag.
Link
Jesse C. Slicer
  • 14.6k
  • 1
  • 40
  • 54
Source Link
Rojee
  • 33
  • 3
Loading