Thread: pointers to constants and constant pointers

  1. #1
    C/C++ homeyg's Avatar
    Join Date
    Nov 2004
    Location
    Louisiana, USA
    Posts
    209

    pointers to constants and constant pointers

    This seems to have slipped my mind.

    Pointers to constants are written as
    Code:
    const int* foo;
    right?

    But I have forgotten how to write constant pointers.

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,659
    > const int* foo;
    Read it backwards ( more or less )
    foo is pointer int const.

    A const pointer would be
    Code:
    int * const foo;
    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.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Help with variables and constants.
    By dave1339 in forum C Programming
    Replies: 2
    Last Post: 12-21-2008, 09:18 PM
  2. Constant Being Initialized AFTER Variable That Uses It
    By mercury529 in forum C++ Programming
    Replies: 22
    Last Post: 07-30-2006, 09:51 AM
  3. Forced to use constants
    By Night_Blade in forum C++ Programming
    Replies: 6
    Last Post: 08-08-2005, 04:30 PM
  4. Pointers and constants
    By Jasel in forum C++ Programming
    Replies: 6
    Last Post: 10-24-2003, 08:09 AM
  5. Help with Constants and enum constants. Newbie learning C++.
    By UnregJDiPerla in forum C++ Programming
    Replies: 5
    Last Post: 01-07-2003, 08:29 PM