Thread: checking if this is a typo in the C++ book

  1. #1
    Registered User
    Join Date
    Jul 2018
    Posts
    2

    checking if this is a typo in the C++ book

    Hi! I'm trying to learn C++ and would like to check if this is a typo from page 135 of the ebook as it's really confusing me.

    https://i.imgur.com/MS6uueB.png

    Is the 2nd line of the code supposed to be this?

    int *p_x = & x;

    Or is it also ok to declare pointers without the *?

    Thanks!
    Last edited by kigwa; 07-29-2018 at 07:40 AM.

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    37,378
    Your correction is correct!
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  3. #3
    Registered User
    Join Date
    Jul 2018
    Posts
    2
    Thank you!

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Homework typo
    By fetahi3212 in forum C++ Programming
    Replies: 2
    Last Post: 01-12-2017, 03:09 AM
  2. Typo on C-FAQ
    By ssharish2005 in forum General Discussions
    Replies: 3
    Last Post: 06-06-2011, 05:24 PM
  3. basic recursion function question. typo in book?
    By navyzack in forum C Programming
    Replies: 6
    Last Post: 04-18-2005, 11:07 AM
  4. typo on faq
    By chrismiceli in forum Linux Programming
    Replies: 2
    Last Post: 10-06-2003, 03:23 PM
  5. typo
    By ygfperson in forum C++ Programming
    Replies: 2
    Last Post: 04-18-2002, 01:25 AM

Tags for this Thread