Thread: const unsigned int vs unsigned const int

  1. #1
    Registered User
    Join Date
    Oct 2015
    Posts
    12

    const unsigned int vs unsigned const int

    Take the following code as an example for this question:

    Code:
    void mean(const unsigned int answer[]);
    void median(unsigned int answer[]);
    void mode(unsigned int freq[], unsigned const int answer[]);
    void bubbleSort(int a[]);
    void printArray(unsigned const int a[]);
    What is the difference between const unsigned int and unsigned const int? In either case the unsigned simply makes it so negative numbers cannot be used...

  2. #2
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    Quote Originally Posted by jmcquaid1987
    What is the difference between const unsigned int and unsigned const int?
    Word order; they are equivalent.
    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
    misoturbutc Hodor's Avatar
    Join Date
    Nov 2013
    Posts
    1,787
    In this case they are semantically equivalent, as laserlight mentioned. It might get tricky with some more complex examples though, depending on how experienced you are.

    This might be handy Clockwise/Spiral Rule

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 2
    Last Post: 10-06-2009, 09:37 AM
  2. Replies: 7
    Last Post: 04-28-2008, 09:20 AM
  3. Replies: 2
    Last Post: 04-21-2008, 07:43 PM
  4. Replies: 7
    Last Post: 02-08-2008, 06:31 PM
  5. casting const unsigned char * to string
    By Unregistered in forum C Programming
    Replies: 1
    Last Post: 06-06-2002, 08:51 AM