pointers to constants and constant pointers

This is a discussion on pointers to constants and constant pointers within the C++ Programming forums, part of the General Programming Boards category; This seems to have slipped my mind. Pointers to constants are written as Code: const int* foo; right? But I ...

  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 wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,672
    > 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.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

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, 08: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, 07:29 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21