Thread: unsigned data type?

  1. #1
    Registered User
    Join Date
    Sep 2002
    Posts
    70

    unsigned data type?

    what is the deal with the unsigned data type, e.g.

    unsigned int ...etc

    what is the unsigned data type & what is it used for?

    & also what are the #ifdef & ifndef compiler directives used for??

    (i am a beginner)

    any help will be appreciated...

  2. #2
    Veni Vidi Vice
    Join Date
    Aug 2001
    Posts
    343
    When you declare a variable as unsinged it cannīt contain negative values. The advantage with declaring a variable as unsigned is that it can store larger values than signed.

    E.i when you declara a varaiable as
    Code:
    unsigned char uc; //range from 0 - 255
    signed char sc; // -126 to 127 (or something)
    & is used when you want to declare a reference (an alias) to an object.

    & also what are the #ifdef & ifndef compiler directives used for??
    I think they are called inclusion gards. They are used so that e.i a class isnīt compiled twice (or more).
    Last edited by ripper079; 11-09-2002 at 05:45 AM.

  3. #3
    Just a Member ammar's Avatar
    Join Date
    Jun 2002
    Posts
    953
    I think they are called inclusion gards. They are used so that e.i a class isnīt compiled twice (or more).
    This is if you've included the same headerfile twice.

    & is the refrence, you give it the address of a variable so you will be able to use it to access the variable, it's important when you call functions and pass an object to them, you use the refrence which prevent's making a copy of the objects, and saves momory.
    Last edited by ammar; 11-09-2002 at 06:31 AM.

  4. #4
    Registered User
    Join Date
    Apr 2002
    Posts
    362
    Perica,

    As you can see, you need to be careful when writing out your questions. You'll probably want to be more judicious with using the ampersand (&) rather than the word, "and", in the future. (You had me a little confused, too.)

    -Skipper
    "When the only tool you own is a hammer, every problem begins to resemble a nail." Abraham Maslow

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Reading a file with Courier New characters
    By Noam in forum C Programming
    Replies: 3
    Last Post: 07-07-2006, 09:29 AM
  2. Question on l-values.
    By Hulag in forum C++ Programming
    Replies: 6
    Last Post: 10-13-2005, 04:33 PM
  3. Please Help - Problem with Compilers
    By toonlover in forum C++ Programming
    Replies: 5
    Last Post: 07-23-2005, 10:03 AM
  4. Please STICKY this- vital to MSVC 6 dev - BASETSD.h
    By VirtualAce in forum Game Programming
    Replies: 11
    Last Post: 03-15-2005, 09:22 AM
  5. HUGE fps jump
    By DavidP in forum Game Programming
    Replies: 23
    Last Post: 07-01-2004, 10:36 AM