Thread: Pointers

  1. #1
    Registered User
    Join Date
    Aug 2011
    Posts
    102

    Pointers

    I read something about pass a pointer to a function. And it state that there're four way of passing it:

    • non-constant pointer to non-constant data
    • constant pointer to nonconstant data
    • non-constant pointer to constant data
    • constant pointer to constant data


    So, what does non-constant pointer and constant pointer means?

  2. #2
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    Quote Originally Posted by ncode
    So, what does non-constant pointer and constant pointer means?
    For example:
    Code:
    int *p1 = 0;
    p1 is a non-constant pointer; you can point it elsewhere later.
    Code:
    int *const p2 = 0;
    p2 is a constant pointer; its value cannot be changed.
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  3. #3
    Registered User
    Join Date
    Aug 2011
    Posts
    102
    oo ok thanks. Didn't figure it out it's cause by const. Thanks

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. size of struct with pointers and function pointers
    By sdsjohnny in forum C Programming
    Replies: 3
    Last Post: 07-02-2010, 05:19 AM
  2. Storing function pointers in generic pointers
    By Boxknife in forum C Programming
    Replies: 6
    Last Post: 08-01-2009, 01:33 PM
  3. Pointers to objects -- passing and returning pointers
    By 1veedo in forum C++ Programming
    Replies: 4
    Last Post: 04-04-2008, 11:42 AM
  4. Problem with malloc and pointers to pointers
    By mike_g in forum C Programming
    Replies: 7
    Last Post: 03-29-2008, 06:03 PM
  5. weak pointers and use_count smart pointers
    By Mario F. in forum C++ Programming
    Replies: 2
    Last Post: 07-29-2006, 07:54 AM